javascript-events

Programmatically determine the DOM element to add the 'scroll' listener to

I'm writing a Firefox add-on and most of the time using document.addEventListener("scroll", scrollListener, false); works just fine. However on cuil.com that doesn't work. Basically any site that has a fixed header or footer that doesn't scroll causes a problem with the above code. How do I determine which element to add the event li...

Find Duplicate Values in the Gridview using Javascript

Hi all, I have a following requirement. I have a Gridview contains two columns Model Name | Model Description Model A | Model A Desc | Edit Update Cancel Model B | Model B Desc | Edit Update Cancel Model C | Model C Desc | Edit Update Cancel Let's when user click E...

How do I attach a jQuery event handler to a YouTube movie?

[EDIT: Sorry to those who already answered -- in my sleep-deprived state, I forgot that this particular situation is a YouTube movie, not the JW FLV player. I can see that there is more extensive documentation on interacting with YouTube movies, so I will pursue that, but any more information is also welcome] I am using embedded YouTube...

Confirm Delete on Javascript Remove Event

I'm using a javascript call to dynamically remove a field from a form. My problem is that the action happens very quickly, and it's not reversible. So I'd like to add the standard Rails delete confirmation, but I can't figure out how to make it work. Basically, I want to add this ... :confirm => ‘Are you sure?’ Here's the line of j...

Dynamically Generated Select Menus Not Holding State in Edit View

I'm following Railscast 88 to create a dynamic dependent dropdown menu. http://railscasts.com/episodes/88-dynamic-select-menus I'm rendering these dropdowns inside a partial that I'm using in a multi-model form. The form I'm using follows the Advanced Rails Recipes process by Ryan Bates. Because I'm rendering the dropdown inside a ...

addEventListener in Canvas tag

Javascript - Canvas tag - HTML5 Hello, I have a canvas tag to create a graphic. At each section of my line, I have a "dot" to enable a 'mouseover' and display more detail. Everything works fine when I don't add an event listener to this dot. Firebug is warning me : s.addEventListener is not a function... Is it possible to create dyn...

How to wrap the click event with some custom function

I have a button called 'create project', when user click the button, i want 2 things to happen an ajax call to check if the user is allow to create a project if allowed, then execute the button as normal, if not, then pop up a modal dialog saying he is not allowed to create a new project. I have the following code $('.create_proje...

javascript setTimeOut function within a jsp

I am trying to use the timeout function within a jsp. But it doesn't work. <script language="javascript"> function hol_logs() { var myAjax = new Ajax.Request( "getlogs.jsp", { method: 'get',parameters: 'jobId=<%=job%>', onComplete: zeige_logs } ); setTimeOut("hol_logs()", 10000); } function zeige_logs( orig...

delegate in javascript

i'm having a function where i need to call another function which 'll we dynamic jus i know the function name. like my function is myfunction(obj){ otherfunction(?); } otherfunction maybe otherfunction(obj){ } or otherfunction(){ } i dono know whether to pass the parameter or not. how can i call the method ...

Exit survey popup

I'm trying to create an exit popup to conduct an exit survey for a site I'm working on. The most common solution I've come across is to catch the page onunload event, and add an event handler to all link click events to block the popup. example: http://www.pgrs.net/2008/1/30/popup-when-leaving-website There are a couple of issues with...

JavaScript onKeyPress assigning problem

I am trying to add an onKeyPress event to a dynamically created html element using javascript. In practise, the element is added, the id is assigned, and the innerHTML added, but the onmouseover, onmouseout, and onKeyPress (2nd last line) events are not added to the element. The last line (.focus()) does work. Code: function newParagr...

Why does $.change() fire on a submit button?

I have a $.change() event, but when a submit button is pressed, the change event fires again. It is only supposed to fire once when a text is inputted into a input text box. $('input:submit', top.document).bind('click', function (e) { alert("submitting") }); $('input').change(function (e) { alert("fire"); }); ...

Variables in Anonymous Functions -- Can someone explain the following?

I've been trying to assign a function to onclick event of a dynamically created "a" tag in JavaScript. All of the tags are created in a loop as follows: for ( var i = 0; i < 4; i++ ) { var a = document.createElement( "a" ); a.onclick = function( ) { alert( i ) }; document.getElementById( "foo" ).appendChild( a ); } The alerted v...

Access event object in event handler

When i try to attach event handler functions with parameters like : myhandle.onclick = myfunction(param1,param2); function myfunction(param1,param2){ } Now I want to access the event object in my handler function. There is an approach mentioned on the web of sending event object, like: myhandle.onclick = myfunction(event,param1,para...

Firefox extension to find out which Javascript event is bound to an inspected element?

One can bind Javascript events to html elements without using inline declarations. Is there a way when inspecting an html element to know which events are bound to the element? I want to know about the events defined by the developer and not the internal ones that come with the browser. So if I hover over an element and a menu shows up...

Javascript event css background image loaded

Is there any way to detect that a css background image has been loaded? By using normal tags this would be easy but I need to use a css background because I'm placing divs over the image. The reason why I need to detect that this image has been loaded is that I don't want to start preload additional images before the background image is...

Interactive Javascript Bar

Hi all, I'm looking for a way to create an interactive bullet graph, which will allow the user to click anywhere in the graph and set a marker, then calculate some simple values based on where this marker is at. For example, I'd like it to look similar to this: http://www.usrecordings.com/test-lab/bullet-graph.htm Yet, allow the user...

Forcing javascript keyboard event inside a textarea on IE

Hi I'm trying to force a keypress inside a textfield using javascript. This has to work specifically on IE but it simply doesn't work. Can anyone help me? My test script is this one: <html> <body> <input type="text" id="txtfld"> <input type="button" onclick="go()"> <script> function go() { var q = document.getElemen...

Pass backspace key pressed event to the applet and stop it propagation

I have a java applet on web page that allows editing text. When user tries to modify text, pressing backspace button, browser forwards to previous page. If filter backspace pressing like var a = function () { var event = window.event; if (event.keyCode == 8){ alert('backspace'); return false; ...

How to Maintain a persistent state of the drop down?

Hi All, I am making a simple web app that has drop down list in the first page in a form tags. Now wen I change the value in the dropdown the form is submitted. On the onchange I have made call to create a query string custom JS function of the selected Index. Now I want the drop down list to maintain its state; keep the last selected va...