[thelist] safe js

Maximillian Schwanekamp anaxamaxan at neptunewebworks.com
Wed Mar 17 11:26:05 CST 2004

Manuel said:

<a href="foo.html" onclick="foo();return false;"
onkeypress="foo();return false;">
function foo() {
if (!document.getElementById) { return; }
// Blah, blah, blah...
>Is there a way i can make old browsers ignore the 
>onclick and fallback to the href?

Perhaps instead of return null, return true or false:
<a href="foo.html" onclick="return foo();" onkeypress="return foo();">
function foo() {
if(!document.getElementById) {return true; }
// do stuff, then...
return false; // (assuming you're not going to foo.html of course)

Or, perhaps instead of returning, use 1997-era js to go to foo.html:
if (!document.getElementById) { window.location='foo.html';}

More information about the thelist mailing list