Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Web
Expertise: Beginner
Dec 15, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

How to Write Backward Compatible JavaScript Links

Although most people have JavaScript enabled on their browsers, there are still a lot of people who don't. This is why you should always make your pages as backward compatible as possible. One easy way to improve access is with pop-up window links (where you click somewhere and a page appears in a small pop-up window). Usually, you'd write:
<A HREF="javascript:popup('page2.html');">link</A>

Instead, try using the onClick handler to handle the JavaScript:
<A HREF="page2.html" TARGET="_blank" onClick="popup_
('page2.html');return false;">link</A>

The link will display the page in a new window for non-JS browsers and the "return false" ensures that newer browsers only perform the (more controllable) JavaScript pop-up. onClick="return false;" can also be useful in stopping <A HREF=#> links from taking you to the top of the page, and of course they remain backward compatible!
Andrew Skeen
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date