JavaScript: calling events inline
March 13, 2009
/ Filed under: JavaScript, PHP, HTML
There are a few different ways to call events in JavaScript - the most popular being as inline attributes. There is often some confusion surrounding the proper way to designate JavaScript events inline, while maintaining application composure if JavaScript is turned off. The most commonly used approach looks something like this:
Here we use a "pound" or "hash" character as the Ideally, you should provide a real location as the
The above approach is safer, because if JavaScript is turned off, the browser will simply go to
function my_function()
{
window.location = "page.htm";
}
With JavaScript turned on, the browser acknowledges the Same for
Comments/Mentions
|
Editor Picks
Email NewsletterSubscribe to the digest newsletter to receive posts by email: Recent Comments
Advertisements
|