javascript-events

Can I change the context of javascript "this"?

var UI$Contract$ddlForm_change = function() { debugger; //'this' is currently the drop down that fires the event // My question is can I change the context so "this" represents another object? this = SomeObject; // then call methods on the new "this" this.someMethod(someParam); }; is this possible? Thanks, ~ck in San Di...

Stop events from triggering after they've been triggered once

I have the following code: $('body').mousemove(function() { $('#covering').fadeOut(500); $('.block div div').fadeOut(250) $('.block div div').css('margin-top','160px') $('.block div div').fadeIn(250); }); Basically what I am trying to do is have have a "covering" div fade out (as in this question) and have a few block elements's i...

Script to hide status bar messages in Firefox, IE, Opera, Safari ?

Hi, Currently I am using this OnMouseOver="window.status='';return true;" for <asp:LinkButton ID="lnkCategory" runat="server" onMouseOver="window.status='' ; return true;" onMouseOut="window.status='';" oncontextmenu="window.status=''; return true;"> This works fine in IE but not in firefox. How can I able to change this. I wa...

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: function setKeyHook() { logMessage("setKeyHook()"); top.frames.BOTTOM.document.onkeydown = top.frames.TOP.document.onkeydown = function( evt ) { return function(){ t...

Click event fires in IE/Firefox, but Chrome is dropping the event assignment

I'm in the process of debugging my web application and have hit a wall. I'm experiencing a behavior in Google Chrome only and my javascript ineptitude is keeping me from the solution. I have an ASP page with an <asp:Panel> control. Within the panel, I've setup a simple search textbox and am using an <asp:LinkButton> to launch the sear...

Listener for property value changes in a javascript object

Going through javascript documentation, I found the following two functions on a javascript object looks interesting: Watch - Watches for a property to be assigned a value and runs a function when that occurs. Unwatch - Removes a watchpoint set with the watch method. Sample usage: o = {p:1}; <br/> o.watch("p",<br/> function (id,old...

What's the best way to write a standards compliant popup window with XHTML and Javascript?

I'm writing standards compliant XHTML Strict 1.0, so including the HTML "target" attribute on anchor elements will not do. I've read 2 fundamentally different ways using Javascript: Upon document load, find all links with rel='external' and append the target='_blank' attribute. Use the HTML onClick attribute that fires a Javascript po...

What is the difference between this.click() and $(this).click() ?

In the end, I have decided that this isn't a problem that I particularly need to fix, however it bothers me that I don't understand why it is happening. Basically, I have some checkboxes, and I only want the users to be able to select a certain number of them. I'm using the code below to achieve that effect. $j( function () { $j(...

check if javascript is enabled and display a message if it is not using an asp custom control

Hi, I'm using Javascript, ASP.net and c#. I want to write a custom control to check if javascript is enabled on the browser and display a message. I'm using the following approach: -the control shows a message "Javascript disable" in a tag -the control adds in the section a javascript section with this line: window.onload = function()...

Close popup window if it exists

Hi, With some javascript I openup a popup no prob using: function myPopup2(x){ if (x==1) { myWindow = window.open( "timer.html", "", "height = 150, width = 300" ); }else { myWindow.close(); } } I then run some PHP script which refreshs reloads the page. When I later then go to close the popup - it...

How performance-hungry are events in Prototype (JavaScript)?

Does anyone know if using custom events in Prototype (using Element.fire and Element.observe ) affects performance? Also would I gain performance if I use global variables instead of events? Thanks! ...

Accessing an object's property from an event listener call in Javascript

Below I am creating an object in Javascript. Within the constructor I am setting up an event listener. The problem is that when the event gets fired, this.prop cannot be found, and undefined prints out. How do I solve this? var someObj = function someObj(){ this.prop = 33; this.mouseMoving = function() { console.log(this...

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 either s...

detect when all events from a mouseevent have fired?

I want to know when all of the events for a mouse event have fired. For example, if I have registered listeners on document and an element, then click the element, i could get multiple events firing (more if the resultant events are bubbling). How would i know when all events resulting from that click have completed? This site provide...

how to stop onChange in javascript

in one of my selection box, i have a onChange="..." specified... coz i want to change some other form value after any selection changes. however ... in the same page, some wired case i have to manually set the value.. so i have to use some javascript to set the value of the selection combox, but in this case, i don`t want that onChange ...

How to trigger this event?

I have two password inputs. They are both entered by the password keypad, but no keyboard input. The keypad is a 3 by 3 table with button 1 to 9. How can I trigger the event when the client mouse cursor leave the keypad table? What I wanna do is if the user click something and then leave the keypad, so validate the confirm password inp...

How do I get the particular element instance when an event is registered for multiple elements having same class

How do I get the particular element instance when an event is registered for multiple elements having same class ? Code Event.observe(document, 'dom:loaded', initBookingHistory); function initBookingHistory() { hideJourneyDetails(); ObserveJourneyDetailsForClick(); } function ObserveJourneyDetailsForClick() { $$('....

What is the difference between the mouseover and mouseenter events?

I have always used the mouseover event, but while reading the jquery documentation I found mouseenter. They seem to function exactly the same. Is there a difference between the two, and if so when should I use them? (Also applies for mouseout vs mouseleave) ...

Catching Tabs in TextArea

Does anyone know a cross-browser, reliable solution for catching presses of the tab-key in a textarea field, and replacing (in the correct position) 4 spaces? The textarea is being used to input an essay, and needs this feature. Note: I tried using FCKEditor, among others, which did not catch tabs and had a bunch of features I didn't n...

javascript event inheritance

I'm using a list to build a simple nav menu, that shows when you hover and hides when you leave it. I want the menu (ul) to appear when the a tag is hovered, and only disappear when mousing out of the entire div. However, the code below is hitting the mouseout when every tag is moused out, not just the div tag. I assume each child tag...