javascript-events

When does script added with RegisterStartupScript() execute?

When does script added to the page with Page.ClientScript.RegisterStartupScript() actually run? MSDN states "when the page finishes loading but before the page's OnLoad event is raised" but this isn't much detail. For example, can a script added with RegisterStartupScript assume the DOM tree has been built? Does the behaviour differ bet...

Avoiding a javascript race condition

Here's the scenario: My users are presented a grid, basically, a stripped down version of a spreadsheet. There are textboxes in each row in the grid. When they change a value in a textbox, I'm performing validation on their input, updating the collection that's driving the grid, and redrawing the subtotals on the page. This is all ha...

How do you execute a Javascript function without 'onclick' like "Grippie" in a new post on SOF

Such as the <div class="grippie" style="margin-right: 59px;"/> on stackoverflow when you post a question or answer. I get a nice css curser which lets me know of the moveable edge but how is the Java script which resizes the field finding out I clicked on the 'Grippie'? Thank you. Edit: Thank you for the answers which lead to Jque...

jQuery Event To Detect When Element Position Changes

I would like to know if there is a jQuery event that I can use to determine when a particular DIV's "Top" property has changed. For instance, I have invisible content above a DIV. When that content becomes visible the DIV is shifted down. I would like to capture that event and then use the offset() function to get the X/Y coordinates....

Why doesn't this javascript (jQuery) go into an infinite loop?

I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery) on Karl Swedberg's blog, and I became totally puzzled at this part of the code (simplified for brevity): function addItemUnbind() { $Add a button but it won't have it's event added; addItemUnbind(); }); Why is...

Workaround for IE's Non-Bubbly Submit Events

I'm working on a large web application with a lot of AJAX whose event handling has gotten out of control. I'm trying to set up an event delegation system to manage all of it, but am wondering if there's a workaround for IE's non-bubbling form submits (there are a lot of forms that get inserted/updated via AJAX). The best thing I've com...

How do I capture response of form.submit

Hi All, I have the following code: <script type="text/javascript"> function SubmitForm() { form1.submit(); } function ShowResponse() { } </script> . . . <div> <a href="#" onclick="SubmitForm();">Click</a> </div> I want to capture the html response of form1.submit? How...

Modifying the window opened by javascript's "window.open()" function

Here's my scenario: I have a page containing several links; each link is meant to open another window containing a pdf. The catch is, I can't have that window directly go to the PDF because I do not want to make it apparent to the end user the PDF is located on another domain, and I need to name the PDF differently than how it would re...

How to find out user clicked 3 times through my website with javascript

Is there any way in JavaScript how to find out user clicked through the same domain 2 or more times? I need to popup a window after user clicked anywhere on the site for 3 times. I know how to do it after one click - with document.referrer or addEventListener, but then I'm lost. I need something that will capture all click events (not ...

Trigger button event when press enter key on mozilla firefox

function CaptureKeys (e,btn) { var c //= document.layers ? evt.which: document.all ? event.keyCode : evt.keyCode if(window.event) // IE { c = e.keyCode; } else if(e.which) // Netscape/Firefox/Opera { c = e.which; } if (c == 13) //return /enter key { if (btn=="go") { if (document...

Any examples of Flot with floating tooltips?

I am currently working on a Flot graph, the API which seems pretty powerful overall, although examples of advanced use are not widely documented. The API suggests there are ways to set hoverable on the graph, not that I am sure what exactly that means I can do with it. I would like to know if anyone could contribute some examples tha...

Javascript To Get An Alert To Redirect When Closing The Browser Window

Hello Everyone, I'm trying to get this Javascript to work properly. My intention is, when a user is trying to close the site page to get an alert saying "stay on current page or close" If they hit 'ok' I want it to close, if they hit 'cancel' i want it to redirect to another page. The problem is, when they try to go to another page on t...

Javascript Onclick Problem with Table Rows

Hello. I am having problems with my JScript code. I am trying to loop through all of the rows in a table and add an onclick event. I can get the onclick event to add but have a couple of problems. The first problem is that all rows end up getting set up with the wrong parameter for the onclick event. The second problem is that it o...

How do I disable tabs for <a> tag

Hi, I am using tags for links on a web page. How do I disable tab key from selecting either of them. ...

Pass parameters in setInterval function

How to pass parameter while call a function using setInterval. viz. setInterval('funca(10,3)',500); is incorrect. ...

How to set a focus to an input field in method invoked after onchange() event?

Hello, I've got problems with setting focus to an input field after validating it. I've got 2 fields: from and to. <spring:message code="template.fields.label.from"/>: <mvc:input path="templateFields.selectorRangeFrom" onchange="validateNumber('templateFields.selectorRangeFrom',true)"/> <spring:message code="temp...

Javascript close alert box

I want to be able to close an alert box automatically using javascript after a certain amount of time or on a specific event (i.e. onkeypress). From my research, it doesn't look like that's possible with the built-in alert() function. Is there a way to override it and have control over the dialog box that it opens? Also, I don't want ...

Passing arguments to anonymous javascript functions

Consider the code below: this.usedIds = 0; this.SendData = function(data) { var id = this.usedIds; this.usedIds++; this.xmlHttpThing.open("POST", "/Upload.aspx", true); this.xmlHttpThing.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); var currentObject = this; this.xmlHttpThing.onreadyst...

JQuery Click event not being triggered in Safari?

I'm trying to do something when a user selects an option from a select box - As simple as can be right? I'm using JQuery 1.3.1 to register a click handler with the id of the select box. Everything was fine until I tested using Chrome and Safari and found it didn't work. Firefox 3.05 - YES I.E 7.0.5730.13 - YES IE6Eolas - YES Sarafi 3...

What JavaScript events are available to WebKit on Android?

I'm building a mobile web app targeting Android users. I need to know what JavaScript events are available to me. I have been able to make the following work, but not terribly reliably: click mouseover mousedown mouseup change I have not been able to get the following to work: keypress keydown keyup Does anyone know the full list...