Xah Lee wrote:
Your code is (pretty-printed):
function f()
{
if (window.top.location.href != window.self.location.href)
{
window.top.location.href = window.self.location.href;
}
}
window.setTimeout(f,1000*3);
Following <URL:http://jibbering.com/faq/#FAQ4_43> would have told you that
it causes
Quote:
Error: uncaught exception: Permission denied to get property Location.href |
You are attempting to read `window.top.location.href'. Since the domain
of the frameset document's URL is "images.google.com" and the domain of the
URL of the frame document that contains the accessing code is "xahlee.org",
the Same Origin Policy forbids that. Do not compare locations but compare
object references instead.
Your window.setTimeout() call is unreliable; if window.setTimeout(), a
host object's method, is not supported, your script breaks; if it takes
more then 3 seconds to load the frameset completely, your script breaks;
if Function object references are not supported as first argument of
window.setTimeout(), your script fails or breaks.
Either or both may be the reason why no further script code (e.g.
`alert(...)') is executed then. Furthermore, `window.self' is
referring to the same object as `window' does, so it is inefficient
to use the former.
Try this:
function isMethodType(s)
{
return (s == "function" || s == "object");
}
if (typeof window != "undefined"
&& isMethodType(typeof window.setTimeout)
&& isMethodType(typeof window.clearTimeout))
{
var f = function()
{
if (typeof window.top != "undefined")
{
if (window.top)
{
if (window != window.top)
{
window.top.location = window.location;
}
else
{
if (typeof f.timeout != "undefined")
{
window.clearTimeout(f.timeout);
}
}
}
else
{
f.timeout = window.setTimeout("f()", 3000);
}
}
};
f();
}
Quote:
however, it works in safari, but not in Mac Opera nor Mac Firefox nor
iCab. However, it all works if run from localhost with the frameset and
top frame from downloaded google. |
The domain (localhost) is the same then.
BTW: Your markup is not Valid. <URL:http://validator.w3.org/>
BTW 2: This has nothing to do with stylesheets, so do not crosspost to
comp.infosystems.
www.authoring.stylesheets.
F'up2 comp.lang.javascript
PointedEars