javascript-events

Javascript onkeypress

I have a question regarding the onkeypress event on Javascript. Is it possible to detect Just Ctl key or Alt Key? At the moment if both Ctl and m are pressed the onkeypress event can trigger a click. Is it possible to do just Ctl key by itself? Looking forward to your comments ...

What is the event to catch form submission in Javascript?

A couple of questions here: I was wondering what event do I use to execute some javascript on form submission (to do some validation)? Once I have done my validation, how do I then submit the form in javascript ? Cheers... ...

Short-cut in textarea

I'm trying to write a text editor. I'd need to: be able to understand what text is selected so that a shortcut could work in the correct portion of text, just like in this editor, if I select a word in the middle of the text and then press Ctrl+B Be able to catch when some keys are pressed like this Ctrl+B and TAB any hint? ...

JavaScript event handler to initiate after 3 seconds

I need to initiate the event handler after 3 seconds of being focused on an image. How should I go about it? Also, I need to trigger another event handler, when I am at a particular part of an image, say the approximate middle of the image. How do I do this? ...

How do I access the onresize event from a SharePoint Web Part?

I have some JavaScript that will execute within a SharePoint web part. I would like to have a function execute when the window is resized. Normally I would use <html> <body onresize="resizeFunction();"> </body> </html> but in SharePoint things start to get hairy. I have an onload function that I am able to use thusly: _spBodyO...

Can I tell anything about a hyperlink that was clicked in JavaScript?

If I have code like this: <script> function determine() { // ???? } </script> <a href="blah1" onclick="determine()">blah1</a> <a href="blah2" onclick="determine()">blah2</a> Is there a way in determine() to see which link was clicked? (Yes, I know, the easy and correct thing to do would be to pass "this" to determine()...but in ...

How do you execute a Javascript function when the page has fully rendered?

How would you go about executing a Javascript function when the page is fully rendered (Displayed) I know that the onLoad event executes when the page is loaded but Before it's rendered. I've previously solved this problem by using a timeout with a 0 interval, which seems to work usually, but seems a little inelegant to my delicate sens...

Lazy loading the addthis script? (or lazy loading external js content dependent on already fired events)

I want to have the addthis widget available for my users, but I want to lazy load it so that my page loads as quickly as possible. However, after trying it via a script tag and then via my lazy loading method, it appears to only work via the script tag. In the obfuscated code, I see something that looks like it's dependent on the DOMCont...

How to execute both the local as the global ajax events in jQuery?

Recently making the switch from Prototype to jQuery, I am struggling with some basic issues. I use several AJAX-requests in my application; for 95% of these requests, I'd like to have some global events executed, such as showing or hiding a loading indicator. Apart from the global functionality, every request should also have some custo...

How to call public method from a event handler

I have the function below. Everything works fine except for the Push, Pop and Remove method. These method should be called by the event-handler. This event is fired by the google maps api. The problem is that when the event is fired, these method are not found. I have a "Push is not defined" error message. I tried with this but that's ...

Javascript global error handling

I would like to catch every undefined function error thrown. Is there a global error handling facility in Javascript? The use case is catching function calls from flash that are not defined. ...

Anyone using yui logger to track yui events? Is there a way to filter it?

The problem that I'm having with it, is that it tracks all the events in the log reader, too. This makes it very difficult to work with. As I scroll up down, click or move in the reader to examine events, it's scrolling all over the place adding new events. Is there a way to filter it to only include certain events from certain sources? ...

Javascript IE Event

This works in Firefox, but not IE. Any help would be much appreciated! Thanks! var form = document.getElementById('theform') /* create the event handler */ form.gen.onclick = function( evt ) { var f = evt.target.form var y = f.year.value var m = f.month.value genCalendar( document, y, m, 'theCal...

Firing a Keyboard Event in JavaScript

I'm trying to simulate a keyboard event in Safari using JavaScript. I have tried this: var event = document.createEvent("KeyboardEvent"); event.initKeyboardEvent("keypress", true, true, null, false, false, false, false, 115, 0); ...and also this: var event = document.createEvent("UIEvents"); event.initUIEvent("keypress", true, true,...

Href and onclick issue in anchor link...

I have anchor link with both href and onclick events specified. The onclick sets location.href to server url and href to a other link. When the link is clicked the href event gets called always but onclick event gets called only once (that is only for one anchor link). If i debug javascript it works properly that it calls both href an...

Javascript: multiple events firing from single action

I have an onclick event attached to a region in my page that causes a certain action to fire when the user clicks in it (naturally). I recently added an image to that region. When the user clicks on that image, I want another action to occur, and I do NOT want the action associated with the entire region to occur. However, I find that bo...

Using jQuery to test if an input has focus

On the front page of a site I am building, several <div>s use the CSS :hover property to add a border when the mouse is over them. One of the <div>s contains a <form> which, using jQuery, will keep the border if an input within it has focus. This works perfectly except that IE6 does not support :hover on any elements other than <a>s. So,...

jQuery events are punching me in the face

I've spent the last four hours trying to figure out why my jQuery events are firing multiple times for something that can only happen once. Basically, I have an ad banner that will be rotating images with jQuery. I'm waiting until the page loads to load all the images except for the one that is shown by default: $("#mainadslot").prepend...

Weird IE7 js issue in Drupal

In IE 7 when I click on any javascript link for example "< a href="#" onclick="toggleGroup(); return false;" id="slick-toggle">View Classrooms" the page will refresh. This is occuring in a drupal project I inherited. This problem doesn't happen in IE7 when I run the same script outside of drupal. Even in the drupal admin onclick event...

IE7 Handle Combination Keypress

How can I handle keypresses in Javascript in IE7 that are Key Combinations? For example, I'd like the command "Ctrl + I" to fire my notification script. How can I go about this? ...