javascript-events

SOLVED: What is the OO approach to accessing jQuery plugin methods from my plugin HTML?

I started with this question: http://stackoverflow.com/questions/1875693/multiple-javascript-gadgets-per-page . After reading up on how to build a jQuery plugin I've modified my OO JavaScript object into a jQuery plugin by wrapping my JS object in (function {} { /*my object code*/ }(jQuery)) and adding a function createMyGadget() {...

Javascript key code =/= char code

Hi! I'm binding on the keydown event with jQuery to allow some specific characters in a textbox. I'm trying to make my code cross browser and platform compliant. My main issue is that I can't find a way to map the received key code to a valid char code, especially for key code coming from the numeric pad (decimal separator, is it a coma...

Styling anchor tags without href's--being used to trigger javascript within page

What is the most cross-browser effective way to style anchor tags without href's? I found this article on making the styles apply in older versions of IE by throwing in an href="#". However, I am applying this about halfway down the page and find that it acts as it should; brings you to the top of the page again. This makes the page 'ju...

Security question: Using ajax and events to keep session alive

I know a few sits (such as my bank and my school) that kill a session after their has been idle for a set amount of time. It is my understanding that session activity is determined by users following links or at the very least from some kind of active interaction, like updating a form via ajax. Basically the server gets a request to do s...

Are dynamically inserted <script> tags meant to work?

I have some code where a <script type="text/javascript"> block is dynamically inserted. This block contains a function, which has an <input type="button"> element above it (also dynamically inserted) call it with the onclick attribute. However, it is not working, and Firebug says that the function is not defined when I attempt to click...

jquery synchronize several events

Hi, I have a function that I wanna execute several times for different dom elements, for example element A,B,C, and D. This function is recursive, meaning that when it finishes its execution it runs again, after some timeout, for the same element. Now, I want that element A starts the execution before B,C and D. Also B starts before D ...

clear timeout problem

Hi, I have the following code but the clear timeout doesn't work and I can't understand why, does anyone have any ideas? (Using the Prototype framework) Thanks function foo() { $("navigation").observe('mouseover', function (event) { clearTimeout(bar); } ).observe('mouseout', function (event) { setTime...

javascript, calling a class which contains a constructor to setup click events etc?

Hi there, i am trying to organize my javascript. What i would like to do is have a class for each PAGE rather then just entering javascript straight into a js - is this good practice? Let me explain .. thinking a long of the lines of, i would really appreciated any input, good or bad and ideas on my variable naming... of remember that ...

How can I get auto-repeated keydown events in Firefox when arrow keys are held down?

I've got several editable divs. I want to jump through them by pressing arrow keys (38 and 40). Firefox 3 on Mac OS and Linux won't repeat the events on holding the key. Obviously only keypress events are supported for repetition. As the keys 38 and 40 are only supported on keydown I'm kind of stuck. ...

Javascript Scrolling Images...

I am new to javascript so go easy. I am trying to create a section of a web page to highlight a company's clients. Rather than list them all, I would like to create a auto scrolling effect. For instance, upon landing on the page a visitor sees two logos in the "clients" section, and two seconds later, that area auto displays two new logo...

keydown EventListener not working in IE7 (Javascript)

Hello. I've written this code inside the HEAD tags of my HTML page. It works fine in FF, Chrome and Safaria, but doesn't in IE7. I would like to know how to fix it. <script type="text/javascript"> if ( window.addEventListener ) { window.addEventListener("keydown", function(e) { alert(e.keyCode); }, true); } </script> Thanks i...

Capturing onload event when dynamically loading .js files ?

Is there a capture the on load event when dynamically adding a script tag with JavaScript in IE? The code below works in FireFox and Chrome but not in IE. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" > <head r...

this.select() and javascript events on forms

I have a form box that I want to be always selected. I was able to get it to select everything in the box when it is clicked (using onFocus="this.select()") but I want it to be selected 100% of the time. The text in the box will be always changing, so I tried using onChange="this.select()" but that didn't work. Here's what I have: <...

IE removeChild stops document.click event?

cycle: element onclick someobject.removeChild(objParent) - this is a parent container div of element in step 1 document.click event is never fired. In Firefox it does still fire the event. Fix: setTimeout(object.removeChild(objParent), 0); will not cancelbubble and continue to fire document.click in IE aswell. Is this normal b...

jQuery events work in Firefox, not Chrome

I registered some click events in my code. They function properly in Firefox (Windows and Mac) but don't execute in Chrome (tried Windows and Mac beta). The purpose of the JavaScript is to show the correct number of text inputs based on the value of the select element. Here is the code: http://www.savetherobots.org/users/jkost/substi...

Javascript: image inside dragable div is stalling my drag and drop when dragged

Client has asked that a whole div is dragable, the div contains some text and an image. I converted the div to be a tag and used Mootools draggable goodies to get it all working. That is until the client clicks on the image and starts dragging it in IE. Then the browser thinks you want to drag the image around and ignores the drag and d...

Javascript alert with confirmation

Hi, I have a javascript alert popup on my page. Problem I am having with it is that instead of waiting for the user to actually click the OK button, it simply does a redirect, something it ought to do AFTER the OK button has been clicked. Can anyone please help me tweak my code so as to get this working as it ought to please? function f...

Disabling middle click scrolling with javascript

Background: I am creating a table reminiscent of whenisgood.net, in that it has click-n-drag toggling for table elements. I want to call different types of toggling code when the left, middle, and right mouse buttons activate a mousedown event. By using JQuery, I'm off to a good start. $(".togglable").bind("contextmenu", function() {re...

How can I detect an address bar change with JavaScript?

I have a Ajax heavy application that may have a URL such as http://mysite.com/myApp/#page=1 When a user manipulates the site, the address bar can change to something like http://mysite.com/myApp/#page=5 without reloading the page. My problem is the following sequence: A user bookmarks the first URL. The user manipulates the appl...

Writing numeric words with onkeypress

How can I write numeric numbers into an input field by pressing a button? Suppose I have a button <input type="button" value="1"> Then I want, that when numeric pad button 1 is pressed it ads numeric words just like Windows Calculator. ...