Tagged: events

There are quite a few scripts out there for checking whether the Caps Lock key is on. However, the top searches for a helpful JavaScript function turn up a lot of dated, obsolete code that usually doesn’t work or uses techniques that are frowned upon, such as obtrusive JavaScript.

In this article I will show you a modern, unobtrusive, cross-browser way of detecting Caps Lock. See the script

After adding an onbeforeunload event to an enterprise app recently, I noticed that the event would fire whenever the user clicked part of a flash swf. This was occuring even though the user was not leaving the page. In this article, I will show you what causes this and how to fix it. See why inside.

You can find a lot of search engine results when you look for methods to block the highlighting of text in your HTML. Unfortunately, the top results for disabling text selection either aren’t fully supported (the CSS way) or could cause scripting errors. I’ll explain inside.

There’s a lot of syntax to remember when dealing with JS events, so I figured it would be a good idea to compile a reference list that covers all types of events and the proper syntax to use them. See the examples.

In my last scripting article, I showed you how to use native JavaScript to disable mouse wheel scrolling and re-enable it afterwards. Now that you know it (you read it right?), I will show you the simpler MooTools way. All in 2 lines of code.

I occasionally need to block mouse wheel scrolling when I’m working with JavaScript. Of course, this is only momentary, such as when I need to display an overlay of some sort. See how to do it properly

So you want to open a drop down select box without clicking on it? For years, people have been looking for the answer to this question. While everything else on the web has been changing since, the answer to this question remains the same. See the answer

I recently found myself working on a small script that needed to perform some actions upon submission of a form. We decided that this form may or may not have an existing event handlers. If I used the javascript form.onsubmit = function(e){ ... }, it would overwrite the first event. We researched various ways of making sure both events fired and that it worked across all the browsers. See how we add the event without overwriting the existing one.

Welcome to another article on Building Better Web Pages. This article series comprehensively covers building an HTML document: easily learned, but rarely perfected.

Today’s article covers Unobtrusive JavaScript . While we await the day that content is properly separated from presentation and behavior, we will still no doubt come across many remnants of the old way of working with markup. One of these remnants is JavaScript events inline with HTML markup. This includes onsubmit, onclick, onmouseover, etc. The purpose of this article is to show you that, while technically allowed by the current HTML spec, inline JavaScript is a bad idea.

Tagged: events