Tag: javascript events

Removing the Event Listener on a Button programatically

I have a Button which is registered with a onclick event as shown <Input type=”Button” name=”Register” Value=”Register” onclick=”CallMe();”/> Is it possible to programatically remove or deregister the onclick event on this Button?

How to prevent events from raising?

Is it possible that if one event raise prevent others from raising? Example on jsFiddle $(window).click( function(e) { $(“#out”).html(“preventing next event from happening\n”); }); $(window).click( function(e) { $(“#out”).html($(“#out”).html() + “evil event should not write here”); });

Is there a built in way to make custom events in JavaScript natively?

I was playing around with JavaScript a little while ago, and it irritated me that I couldn’t create my own event. I’ve seen Framework’s with this built in (jQuery, MooTools, Prototype. Dojo doesn’t which is weird because it seems to do everything and your laundry) and I actually built my own system for creating and […]

image.Onload does not complete the image

This is driving me crazy. I need to load an array of images in Javascript, but I want to make sure that all the images are loaded before starting drawing them. So, I busy-wait for every image onLoad event to be called. First I create images and set their source and onload function: // Load […]

get character typed, cross-browser

Simple question — Does anyone know of a reliable cross-browser function to get the character typed from a keydown event? I can write one from the quirksmode grid but would rather not re-invent the wheel for something so simple yet so non-standard. Let me clarify: There is no way to do this simply using event.keyCode […]

Undefined properties in localStorage's 'storage' event

The event that should be fired when localStorage is changed seems to be lacking information in Firefox. I set up the following event handler: function storageEventHandler(e){ alert(“key ” + e.key); alert(“oldValue ” + e.oldValue); alert(“newValue ” + e.newValue); alert(“url ” + e.url); } window.addEventListener(‘storage’, storageEventHandler, false); which should be triggered by this: localStorage.setItem(‘foo’, ‘bar’); However, […]

Web page: detect and block certain keyboard shortcuts

I want to detect and block certain keyboard shortcuts on a webpage. For example, say I want to prevent alt-tab for switching apps (just an example, assume any global shortcut) Here’s as far as I can think it out: attach a keyboard event listener to document (or window?) use event.which to check which key combination […]

JQuery $(window).focusout issue

the problem is, I’m making a program like a chat, that needs to know if the user has left the window, or changed to another window or tab, to allow other users see that the other user is not seeing the page right now. I thought the window event focusout would solve my problems, however, […]

strange behavior of marker events in OpenLayer

Hey. I have markers layer on my map. Every time I add a new marker I register it to a mouse-click event: var lonlat = new OpenLayers.LonLat(lon,lat); var marker = new OpenLayers.Marker(lonlat,icon); marker.id = callId; marker.events.register(“mousedown”, marker, function() {AddPopup(marker.id);}); callMarkers.addMarker(marker); Sometimes I want to disable/enable the event. so I use these functions: function EnableAllMarkers() { […]

How to decide execution sequence for Javascript and Jquery function

I am calling two function one Java script and one Jquery function on click of Cancel button. The java script function get executed before Jquery function and I want the exactly opposite. Here is my HTML code <button type=”button” class=”noWarning” id=”cancelButton” onclick=”javascript: showMessage(‘cancelButton’, ‘Cancelling…’); disableButtons(); submitForm(‘${cancelDataRequestFormUrl}’);”> Cancel</button> The Jquery function $(“.noWarning”).click(function() { needToConfirm = false; […]