...

View Full Version : Need version of "onClick" for url's that works in all browsers



markkanning
12-26-2006, 09:57 PM
Hey all,
I'm trying to apply to a div element an onClick event that will mimmick a link(send them to a new page). I've got this version:


onClick="window.location.href('http://www.whatever.com')"

It seems to work fine in IE but not in firefox.
Here's the full code as applied to the div:


<div class="box" id="boxhover" onClick="window.location.href('http://www.whatever.com')">
</div>


I've also tried:


onClick="javascript:window.location.href('http://www.whatever.com');"
<!-- NOTICE THE ADDITION OF THE SEMICOLON -->

Once again, fine in IE, not if Firefox. Does anyone have an approach that's bulletproof for all browsers?

Mark

Mr J
12-26-2006, 10:06 PM
Give this a try

<div class="box" id="boxhover" onClick="window.location.href='http://www.google.com'">Link</div>

markkanning
12-26-2006, 10:11 PM
Thank you, Oh Silent One. I am reaping the bountiful fruits of your wisdom...

In other words, it works great!!!

Thanks,
Mark



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum