RobG wrote :
Eric-Sebastien Lachance wrote:
Hey there,
I decided to just create a 100% height and width div that filled the
space over a background header image, and add an onclick event to
redirect to the my index... Doesn't seem to work in FireFox only, just
in IE. Here's the code:
<div id="headerimg"><div style="width: 100%; height: 100%; cursor:
Due to the differences in how Firefox and Mozilla implement the above
style, the size of your divs are quite different - but that's for a CSS
group to discuss.
hand; cursor: pointer;"
onclick="top.location.href('http://www.monamouchtim.com/');"> </div></div>
This seems to work fine in IE, but doesn't in Firefox. Am I stupid or
am I missing something really important about FireFox?
Yes:
Tools --> JavaScript Console
It will tell you that 'top.location.href is not a function'. Use
<... onclick="location.href('http:...');">...
Sorry but that's wrong.
The answer/solution is:
<div style="width: 100%; height: 100%; cursor: pointer;"
onclick="top.location.href = 'http://www.monamouchtim.com/';"> </div>
or
<div style="width: 100%; height: 100%; cursor: pointer;"
onclick="self.location.href = 'http://www.monamouchtim.com/';"> </div>
If the window is not in a frameset, then calling
top.location.href = 'http://www.monamouchtim.com/';
will be resolved as the calling window.
top means the topmost window in a frameset hierarchy; if there are no
frameset, then top == self. In a sense, the use of top instead of self
may also be better if used to prevent framing.
The problem with the code was the proper use of
location.href.
[window object reference].location.href('...some url')
and
[window object reference].location.href = '...some url';
are 2 different instructions; the first/former is a wrong function call
while the second/latter is an assignment.
Gérard
--
remove blah to email me