javascript-events

How to ensure a DOM element triggers mouseover when it contains a Flash object

I have a div that contains several child elements, one of which is a flash movie. When rolling over this div, I want it to change style to indicate it is rolled over. My problem is that the mouseover and mouseout javascript events don't always trigger, especially if the user moves the mouse over the flash element too quickly. Any sugge...

How to change the style of an element/container when the focus is "inside" it?

Suppose to have a code like this: <div class="notSelected"> <label>Name <input type="text" name="name" id="name" /> </label> <div class="description"> Tell us what's your name to make us able to fake to be your friend when sending you an email. </div> </div> Now suppose I've some...

How to change characters typed in Firefox

I need to change in a text input the character '.' to ',' while typing. In IE I change the keyCode event property in the keypress event, like this document.getElementById('mytext').onkeypress = function (evt) { var e = evt || window.event; if (e.keyCode && e.keyCode==46) e.keyCode = 44; else if (e.which && e.which==46) { e...

How to do page initialization functions in ASP.NET AJAX?

Quick question: There seem to be a number of weird things one could do if one wanted, for hooking up page-load type events. Here are some specific questions: I know about the auto-hooked-up pageLoad function. Are there any others like it? Where do I hook up events like those from, e.g., Sys.Application.add_init or Sys.WebForms.PageReq...

Javascript: How to loop through elements and call onblur handler for certain elements

I have a case where I have a bunch of text boxes and radio buttons on a screen all built dynamically with various DIVs. There are onblur routines for all of the text boxes to validate entry, but depending on the radio button selection, the text box entry could be invalid when it was valid originally. I can't use onblur with the radio b...

Is it possible to listen for changes to an object's attributes in JavaScript?

I'm working on a fiddly web interface which is mostly built with JavaScript. Its basically one (very) large form with many sections. Each section is built based on options from other parts of the form. Whenever those options change the new values are noted in a "registry" type object and the other sections re-populate accordingly. Havin...

Is there a way to determine that the browser window was closed?

How is it possible to identify that the browser's close button was clicked? ...

What is the best way to include the icon in the target region of clickable text?

I am currently using the following javascript to create an expanding menu: http://demo.raibledesigns.com/struts-menu/scripts/menuExpandable.js.src Currently, only the hyperlink text is clickable. What is the best way to have the icon next to the text respond to the click? ...

Asp:RadioButtonList still posts back to server even when client validation fails?

This query is related to this one I asked yesterday. I have a radio button list on my asp.net page defined as follows: <asp:RadioButtonList ID="rdlSortBy" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" AutoPostBack="True" > <asp:ListItem Selected="True">Name</asp:ListItem> <asp:ListItem>Staff No</asp:...

Javascript onHover event

Is there a canonical way to set up a JS onHover event with the existing onmouseover, onmouseout and some kind of timers? Or just any method to fire an arbitrary function if and only if user has hovered over element for certain amount of time. ...

Can anyone explain why this JavaScript causes memory leaks in IE7?

The code is rather long yet simple: 100 leaky JavaScript objects are created. 10 leaky elements are created from the JS objects. 1 element is removed and 1 is added 10000 times. I assume that the detachEvent call is not functioning properly. Also, if you change this.eventParams from an array to a simple variable, the leak goes away. ...

html onresizeend event, or equivalent way to detect end of resize

I'm trying to detect when the onresize event ends in a browser. If I use the "onresize" event, in Firefox it seems to be fired only once, after the resize event ends, which is exactly what I want. But if I try in IE, the "onresize" event gets fired many times during the resize. I also try the "onresizeend" event, advertised in MSDN. But...

What is the event precedence in JavaScript?

What order of precedence are events handled in JavaScript? Here are the events in alphabetical order... onabort - Loading of an image is interrupted onblur - An element loses focus onchange - The user changes the content of a field onclick - Mouse clicks an object ondblclick - Mouse double-clicks an object onerror - An error occurs wh...

How to Stop Click Event From Executing in Javascript Function?

I am trying to assign the onclick event to an anchor tag that already exists when I click on another element. However, everything I've tried seems to result in the firing of the event immediately after assignment. We're using Prototype and Scriptaculous. This is the function: <script type="text/javascript"> function loadData(step, d...

Can event handler defined within javascript object literal access itself?

I know I could do this with closures (var self = this) if object was a function... <a href="#" id="x">click here</a> <script type="text/javascript"> var object = { y : 1, handle_click : function (e) { alert('handling click'); //want to access y here return false; }, ...

Javascript "onMouseOver" triggering for children?

I can't tell if this is a result of the jQuery I'm using, but this is what I'm trying to do: <div class="info" style="display: inline;" onMouseOut="$(this).children('div').hide('normal');" onMouseOver="$(this).children('div').show('normal');" > <img src="images/target.png"> <div class="tooltiptwo" id="tooltip" style="font...

Firefox style onclick arguments in IE

In firefox when you add an onclick event handler to a method an event object is automatically passed to that method. This allows, among other things, the ability to detect which specific element was clicked. For example document.body.onclick = handleClick; function handleClick(e) { // this works if FireFox alert(e.target.classN...

How to Add Event Handler with Arguments to an Array of Elements in Javascript?

I have a three-step process that is entirely reliant upon JavaScript and Ajax to load data and animate the process from one step to the next. To further complicate matters, the transition (forward and backward) between steps is animated :-(. As user's progress through the process anchor's appear showing the current step and previous step...

Why does my custom drag and drop script fail?

Hi all, I am currently trying to code my own JS drag and drop script (out of sheer curiosity and boredom, I know it would be much easier with a framework). My aim is a fully working FF3 version , IE can wait for now. I just got stuck on a weird bug. When I drag the div for the first time, it works ok. When I drag it for the second tim...

Are there any pre-built Javascripts for checking keyboard/mouse activity?

I need a Javascript which monitors keyboard and mouse events to track how much time a user spends on the page. Specifically, actively using the page by typing, or moving/clicking with the mouse. Thought I'd ask if anybody knows of something that might work for me to save some time. Otherwise, Javascript and Aspirin here I come... lol ...