Is there any reason to use one of the following more than the others: And please do not spend your valuable time to tell me to use jQuery or attachEvent/addEventListener. It’s not really the objective of my question. Answer There’s no difference at all between the first two, in this specific situation the semicolon is optional. The third one will
Tag: dom-events
How to run Browser command using jQuery / Javascript?
I have one page in HTML , there are two buttons , save and print. When user click on the Print it should print the page and When user click on the Save page it should Open Save as… Box for that page. Javascript/jQuery solution preferred. Answer For printing you can use window.print(). There is no standard way to trigger
Dynamically creating a textbox with a Javascript onkeyup event that takes parameters
What I have is a single textbox. If the user hits the maxlength of it, I want to create a new textbox and then change focus to it so they can continue typing. To accomplish this, I am trying to dynamically create textboxes that have an onkeyup event tied to them. To do this I am using document.createElement and the
Stop the browser “throbber of doom” while loading comet/server push XMLHttpRequest
(This question is similar to this one, but it’s for using XMLHttpRequest instead of an iframe for Comet.) I’m starting an async long poll like this: If I do this inside <script>…</script> in the head, it will cause the document to keep loading forever. (I’m testing this in Safari on Mac OS X and the iPhone, and it’s the only
Capture mouse position on setInterval() in Javascript
I have a function in Javascript that moves one div depending on the mouse position. This function is set on a setInterval() function and executed every second. I need to capture the mouse position like this: Ps: I cannot use the mousemove event because the function must be executed even if the mouse is stopped. Answer The only time that
JavaScript mapping touch events to mouse events
I’m using the YUI slider that operates with mouse move events. I want to make it respond to touchmove events (iPhone and Android). How can I produce a mouse move event when a touchmove event occurs? I’m hoping that just by adding some script at the top that touchmove events will get mapped to the mouse move events and I
Capture javascript event in IE Mobile
I need to detect the id of the element that generated an onchange event. This code work in most modern browsers: But it does not work in IE Mobile. I have tried the following code, and at least the event is fired and the handler function is called, but window.event is not available when event handler is called: Is there
Escaping double quotes in JavaScript onClick event handler
The simple code block below can be served up in a static HTML page but results in a JavaScript error. How should you escape the embedded double quote in the onClick handler (i.e. “xyz)? Note that the HTML is generated dynamically by pulling data from a database, the data of which is snippets of other HTML code that could have
Javascript event not being set correctly in closure when called cross frame
I have the following code in the top frame of a two frame page: This works on the original document load, but when I call this function from another frame (usually when only one frame reloads), the hook is set, but when the onkeydown function fires, it does not receive the appropriate arguments, instead evt == null. Full Code follows:
image.onload not firing twice in IE7
It works in IE6, and FireFox; but for some reason not in IE7. Using ASP.NET on the Page_Init I populate a list of chapters that are links to the image in the book as well as a Javascript array which holds the pageIDs. ex. Chapter 1 –> href=”javascript:seePage(4);” Here is the actual code I am using: When I click on