Skip to content
Advertisement

Tag: dom-events

In JavaScript e.target is not working as I expected

I have written some JavaScript that opens an element when an element is clicked. However I can’t get the: This is not working to how I want it because: You can open more than one of the showed elements when I only want one open at a time. When I click inside the element it closes, I only want it

Which events are the most intensive?

Which events are the most resource intensive to have attached? Is a mouseover “worst” than a click? Are there any events that are known to be really harsh on the browser? I have my sights on IE7 mainly, as we are seeing performance issues there. We use event delegation where we can. Or, how can I profile events which are

Deactivating and activating an E-mail form

I’m trying to get the code below to keep an E-mail form deactivated until 6 seconds after the page is fully loaded. What can I do to make it work like that? Answer It is not a good idea to hard code the duration. Instead you should call the activate using asynchronous call. Anyways, here is the working code.

In JavaScript, manually controlling order of event listeners

Assuming that FORM contains INPUT, have the following listeners: JavaScript Desired order of firing Nature of problem and attempted solutions Own code at FORM level, formFirst, formLast and middle, but have no access to INPUT code, inputFirst and inputLast – although could add own listeners on the INPUT. Attempt 1 modify formFirst() to create and dispatch a new change Event

Actual key assigned to JavaScript keyCode

I have setup an event listener: When the user presses 2 along with shift, how do I know if I should output (@) or (“)? Each users’ character mapping is different per locale. Answer Use the keypress event instead. It will reliably (barring a few edge cases) detect the character typed. There are a few browser oddities (such as some

Why is event.ctrlKey returning undef?

I am calling a JavaScript function when an option is selected in a select element like so: The function does something like this: According to the alert, e.ctrlKey is undefined – I thought this was supposed to return either true or false? What am I missing here? Answer As per the standard, the attribute ctrlKey is only available on MouseEvents

event.target on Firefox

Works fine on Google Chrome and IE but not on Firefox. Tried it on Google. Google says event.srcElement (works on IE but not on Firefox) so I have added event.target but still not working. Is there anymore changes I need to do to work on Firefox? By the way I’m using 3.5 version of Firefox. Please help me to make

Advertisement