javascript-events

how to get an anonymous function to keep the scoping it had originally when called in an event handler

I have a setup where I get some information, in an ajax call, then I immediately use some of that information for another call, and then I populate some fields. The problem is that I am not certain how to create the anonymous function so that it can call this.plantName. Right now the value of this.plantName is undefined. I know that t...

Javascript in Firefox Plugin: Delay in for loop

I am aware that when coding an extension, there is no way we can delay a function call except for using a setTimeout call but here's what I am trying to achieve in a plugin that I am developing for firefox (this is not for javascript embedded into a webpage by the way): for (var i = 0; i < t.length ; i++) { //Load a URL from an arra...

Unable to get a checkbox to be checked (not a simple question!)

Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything, and its a complex/convoluted environment that my code is in. Okay - here goes. I'm adapting someone else's html/js/css code and trying to get it to work on my server (I've taken permission - please, no comments on that). The main html generates a overlaid...

when is browser done reformatting wrapped text in <textarea>

In JavaScript, how do you detect when the browser is done re-formatting text in a textarea that has line wrap turned on? I've found, especially after pasting a large chunk of text, that the browser continues to re-format & wrap the text long after typing stops. Is there an event of some sort you can look for when it's done? Thanks, Greg ...

Pass parameter to callback function

my code // do ajax request and get JSON response for (var i = 0; i < data.results.length; i++) { result = data.results[i]; // do stuff and create google maps marker marker = new google.maps.Marker({ position: new google.maps.LatLng(result.lat, result.lng), map: map, id: result.id }...

Javascript Postback Event

I have a user control that is supposed to write a value to a hidden field every time the consuming page posts back. Is there any way to trap the postback event at the page level? Perhaps I can wire up an event so that I can run a function every time the page posts back. Thanks. ...

How to get javscript event to fire only when the background is clicked (and not other elements)?

I'm trying to write a web app which replaces the context menu (right-click menu) with my own customized ones. I want it so that when the user clicks on a table row, they get one certain context menu and when they click on the background of the page, they get a different one. I have already written the menus and gotten them working. ...

Javascript image "onabort" event not firing in Firefox & Chrome

I'm trying to work out how to get the onabort event of an image element to work. From reading the docs it's meant to fire when a loading page is stopped either from clicking the stop button or firing the stop event. I can get the following code snippet to work in IE but not in any of the other browsers. What am I doing wrong? <html> <...

How do I open a form on page exit

I'm now dealing with a client request to open a form when the user leave the page. Can that be done? ...

Running an action when mousing over (and leaving) an element (or its child elements)

Imagine I have the following elements: +------------------+ | | | +----------------+ | | | | | | | +----------------+ | | +------------------+ The inner element has positioning that mean it can visually sit outside of its parent, and I put an event listener on...

onDblClick event on a non-editable text box in HTML

Hello all, I need to perform an action on double click of a text box, but the onDblClick event does not seem to register when the text box is not editable (i.e greyed out). Is there something I can do to solve this ? Best, Rohan ...

object expected error javascript

<script type="application/javascript" language="javascript"> function showElement(elementID, show){ var element = document.getElementById(elementID); if (element) { element.className = (show ? element.className.replace(/hidden/gi, "show") : element.className + " hidden"); } } </script> <table cellpaddi...

JavaScript: Very strange behavior with assigning methods in a loop

Consider this code below: <a href="javascript:void(-1)" id="a1">a1</a> <a href="javascript:void(-1)" id="a2">a2</a> <script type="text/javascript"> var buttons = [] buttons.push("a1") buttons.push("a2") var actions = [] for (var i in buttons) { actions[buttons[i]] = function() { alert(i) } } var el...

stopping key event bubbling in safari 4 windows

In safari 4 windows, it does not seem possible to stop some key events from bubbling up to the browser in javascript. This guy got pounced on for trying to stop F5 (a dubious design goal), but the technical problem remains... how do you stop certain key events from bubbling up in Safari 4? For example, You can stop: CTRL+T CTRL+N ...

Javascript event when page is actually shown in a web browser

Hi, I'm developing a web site which shows different images in a loop using cross fading. Now, I want this loop to start no earlier than the page is actually shown by the user. The typical scenario is when the user fires up a new tab entering the url of my site, goes back to an old tab (or opens a new tab), waiting for my site to load. A...

OOP in javascript with callbacks

I want to close my window (just a div with position absolute that is draggable) when I click on the close link This is my code function ApplicationWindow() { this.window = $('<div class="window"></div>'); this.create = function create() { //..... var closeButton = this.window.find('.close'); closeButton...

JS and Prototype : mouseover influencing overlying element, why?

I try to create a mouseover Event on a div wich containt a link. When the mouse pass over the div the background is apply to all div correctly, but when the mouse is over the link the background get apply only to the link, why? The link IS in the div, so logically it should still call my event on the div. ----------------------------...

Responding to the onmousemove event outside of the browser window in IE

In Internet Explorer 7 body onmousemove or document.onmousemove events only seem to fire while the mouse is inside the browser window, not when it's outside. Yet in Firefox the onmousemove event is called correctly when I move outside of the browser window. How can I setup an event to be called outside of the browser window in IE? Goog...

add a dropdown menu on clicking on a text in DOM

Hi, Is there a way i can popup a dropdown menu on a webpage when i click on a text? I have a text that is highlighted. The text is highlighted using span tag. so now i have added a eventlistener - click and when i click i want to popup a dropdown menu on the text. I ahve tried by appending a div to the span and then adding the items as ...

How can i get the destination url in javascript onbeforeunload event?

I've searched for hours, but I couldn't find a solution for this. window.onbeforeunload = warn; This doesn't work: function warn (e) { var destination = e.href; alert(destination ); } Okay, so to clear the things. If the user clicks on a link on the page itself, it is easy, because you can add an eventhandler to all of the ...