javascript-events

Prototype - click event by element class name

I am new to the prototype framework and am trying something really simple and failing. I am trying to respond to a click event on a button like so: $$('.btn').observe('click', respond); function respond(event) { alert("hello"); } Why isnt this working?? Please help! ...

How many elements does it take for event delegation to become worthwhile?

Reading another SO question about jQuery performance, I started thinking about the point when it becomes worth using event delegation rather than binding to elements individually. I was thinking mainly about jQuery, but I suppose it is probably applicable for Javascript in general. Event delegation has two main purposes: allowing han...

InfoWindow closeclick event in GoogleMaps V3 being fired too soon?

Hi, I am noticing that the closeclick event on InfoWindow is being called prior to InfoWindow display in Google Maps V3. Has anyone else seen this? Bug? My misunderstanding of design? Consider the simple example: <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> ...

Observing contents of a specific DIV

Hello, Is there a way to Observe the Contents of a specific DIV, I want to call a function as soon as the contents of the DIV are Changed. This can be a innerHTML replace, a page load. Thanks ...

Handle refresh page event with javascript

Is it possible to use javascript to handle the event of refreshing page? What i want is get notice if user do one of these behaviours: refresh page by pressing F5 close tab or browser enter a new url then press enter on browser to display a warning message? Thanks in advance! ...

Could I intercept and handle the new tab shortcut in Javascript?

I'd like to add a feature to the awesome GleeBox project and it involves intercepting requests to create new tabs (so command-T on OS X). I know this sounds like a bad idea but bear in mind this is for an optional extension! Anyway, is it possible to intercept a modified key-event that is used for a "system" function such as this? ...

Event handler for location.hash changing?

I have a flash document viewer embedded in my page, where the user can view the preview version of the document, and then purchase the full version if they like. Is it possible to have a hyperlink in the document itself "BUY NOW" which would command the browser to do something on the current page without having to refresh? I'm imaginin...

Why jQuery.val( value ) does not dispatch any event from the DOM element?

When we use the method jQuery.Val( value ) over a DOM element to change its value. shouldn't the element dispatch an event informing that its value has changed? -I though the event 'change' was going to be dispatched. If it shouldn't why? Live Demo ...

How do you Javascript style area elements on mouseover?

I've got an image map w/ 20 area elements, only four shown below. I want to style each area so that a blue border appears whenever a user hovers over it - all the area shapes are rectangles. <map id="mymap" name="mymap"> <area shape="rect" coords="0,0,223,221" href="http://..." /> <area shape="rect" coords="226,0,448,221" href=...

Mouseover/mouseenter not fired by browser on animated/moving element

If you have an element that has an animation to move it around, the mouseover and mouseenter events aren't fired unless the mouse is moved by the user. To demonstrate try the block of code below with jQuery. If you put your mouse in front of the moving div so you're not moving the mouse when the div passes by then the mouseover isn't f...

When the user clicks an element: Prevent default action, present menu(s), then resume default action when menu is clicked

Goal When the user clicks an element (with class="menu"), the default action should not be executed. The user should be presented with a menu with options. When an option has been clicked, then the default action should be executed. Problem It's very problematic to stop the original click event in the first place, because it seems imp...

How do I replace an inline JavaScript event handler?

I'd like to use JavaScript only (no jQuery) to replace an inline onmenuclick event handler generated by a third party control with my own. The custom control has added the following HTML to the page: <ie:menuitem menugroupid="200" description="Create a site for a team or project." text="New Site" onmenuclick="if (LaunchCreateHa...

Initiating key strokes javascript

Let's say I have a web page with a header menu, when I click the header menu, it calls a servlet that creates the sidebar. Is it possible that without using the document.getElementById? And just simulate keystrokes "tab" and "enter" via javascript so I don't have to click the menu to view the sidebar? ...

change file extention?

What the best way is change file extention of Java? ...

How to detect all change/click events of HTML select that still has focus?

How can I reliably detect all events that cause the the value of an HTML select to change, while that element still has the focus? For regular mouse input, either the click or change event works fine. For keyboard input (and for mouse input using the scroll wheel), however, the change event doesn't fire until focus is lost. I get around...

What percent of the time is unload or onunload called? And Why?

Hi all, I have heard in the past unload, or onunload, is not always called. However, I would like to know how often it is not called. What conditions lead to it not being called? Is this different for Firefox and IE? Thanks, Grae ...

Event when css is done

At a certain stage, I am applying css to a section of my page. Is there an event one can get once the re-layout has completed? ...

What's Wrong with Age Range Script?

I am working with the script that will be checking the age from the current date and very simple logic that is by taking year input. Here is the code: <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Date Check</title> <script language="javascript" type="t...

Can a jQuery load event fire when adding a dynamic stylesheet in Firefox?

I'm running the following code in jQuery to dynamically load a stylesheet. Its purpose is to allow users to load a custom stylesheet and change the look of a JavaScript widget: this.loadStyleSheet = function(url){ $("<link rel='stylesheet' type='text/css' />").attr("href", url).appendTo("head"); } For a split second the screen app...

Find out which object was clicked on a html5 Canvas

Suppose i have a html5/canvas application in which i can place objects on a drawing-canvas. Some kind of diagram editor, something like Visio (but much simpler) Is there a framework which helps me find which object is clicked/draged? An option is to capture the click-event and iterate over all my objects (in a semi-smart way) and che...