Web Hosting Talk







View Full Version : JavaScript question - why doesn't it work??


PencWeb
06-27-2002, 10:25 AM
Why doesn't this work?

<script language="JavaScript">
if(location.href != "top.location.href") {
location.href = top.location.href;
}
</script>

It works, but it loads and loads forever :p

thanks,
- Shawn

Chicken
06-27-2002, 12:53 PM
Are you trying to break out of frames?

*idiot question*

PencWeb
06-28-2002, 11:00 AM
Yes! That's exactly right - sorry I didn't make my self clear before. Does anyone know the problem?? :(


- S

Jeremy W.
06-28-2002, 11:37 AM
<script language="JavaScript">
if(self.location.href!=top.location.href)
{
top.location.href=self.location.href;
}
</script>

Not sure why your other one would have worked at all. Anyways, this will, put it at the top of your file, in the header, so it checks before the file is loaded.

microsol
06-28-2002, 01:59 PM
<script language='javascript'>if(window!=top)top.location.href=location.href;</script>

Shure that one works. ;)

PencWeb
06-28-2002, 03:47 PM
Thanks so much !! :D

- S