View Full Version : How to Check if page is not in a frame?
thewird
11-04-2006, 11:17 PM
How would I check if a page is not inside a frame and then redirect it somewhere else if it isn't? Thanks.
thewird
felgall
11-05-2006, 01:27 AM
if (top.location == self.location) location.href = 'newpage.htm';
thewird
11-05-2006, 06:53 AM
Oh thanks, thats exactly what I wanted (still didn't test it but it looks right).
Now does anyone know what the variables would be for getting the domain only from the URL? I want to see if the frame's domain matches the top-frame's domain. Thanks.
thewird
you may check also for the host or hostname property of the location object.
See also:
http://www.devguru.com/Technologies/ecmascript/QuickRef/location.html
thewird
11-05-2006, 07:47 AM
you may check also for the host or hostname property of the location object.
See also:
http://www.devguru.com/Technologies/ecmascript/QuickRef/location.html
Would hostname or host be more suited to compare the domain?
thewird
thewird
11-05-2006, 09:19 AM
Ok, I think I got it but it doesn't seem to be working, this is my code...
The code is placed inside the frame but it doesn't direct for some reason.
if (top.location.host != self.location.host) top.location.href = "http://"+location.host;
thewird
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.