A short guide to doing  DEC 27 2001

A short guide to doing JavaScript pop-up windows properly: specify your pop-up function in the href attribute instead of the onclick attribute. If you must use the onclick attribute, specify "javascript://" in the href attribute, not "#" because that will take you to the top of the page, a behavior which is not intended or appreciated by the Web user.

Preferred**: <a href="foo.html" onclick="window.open(this.href);return false;">
Good: <a href="javascript:PopUp()">link</a>
Good: <a href="javascript://" onclick="PopUp()">link</a>
Bad bad: <a href="#" onclick="PopUp()">link</a>

** Milo writes in with an even better method of doing pop-ups: <a href="foo.html" onclick="window.open(this.href);return false;">. Benefits include non-JS browser compatibility and shift/right click compatibility.

kottke.org

Front page
About + contact
Site archives

Subscribe

Follow kottke.org on Twitter

Follow kottke.org on Tumblr

Like kottke.org on Facebook

Subscribe to the RSS feed

Advertisement

Ads by The Deck

Support kottke.org shop at Amazon

And more at Amazon.com

Looking for work?

More at We Work Remotely

Kottke @ Quarterly

Subscribe to Quarterly and get a real-life mailing from Jason every three months.

 

Enginehosting

Hosting provided EngineHosting