"If I hit Ctrl+Alt+Del the computer reboots!"

Anyway, the accepted "normal" solution to this is:

<a href="#" onclick="blablabla(); return false">bla</a>

This makes sure:

- page will validate, as "#" is a valid URL
- link doesn't do anything (expect for jumping to the top of the page) when Javascript isn't active - shift-click stuff shouldn't break things (probably doesn't do what the user wants either, but...) - "return false" makes sure the browser won't follow the link after your JS stuff has run

-Thomas

Am 15.08.2006 um 17:23 schrieb Sam:


There's a lot of old-solutions to this problem lingering on Google, so it's difficult for me to determine if there's a more modern solution to this problem. A customer posted a complaint yesterday about how I'm coding href's when an onclick event is used and the href should not be used. It seems the complaint is that holding the shift key and clicking the link opens a new window pointing to javascript:void(0).

Reminds me: Doctor, it hurts when I hit my head with this hammer... (don't hold the shift key and click might be a solution)

href="#" // I never do this

href="javascript:void(0)" // this is what I do, but I read void(0) is deprecated over null?

should I use something else?

Sam


_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to