Xah Lee wrote:
[color=blue]
> [...]
> I'm trying to kick out image.google.com's top frame when it goes to my
> page.
>
> If you go to
>
http://images.google.com/images?q=milk+tits
> click on the page
>
http://xahlee.org/Periodic_dosage_di...caryatids.html
> it should kick out the google's frame, but it isn't.
>
> If i put a alert() in the script, it won't even popup. But i can't see
> anywhere in google's html that has js or disables js.[/color]
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
| 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();
}
[color=blue]
> 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.[/color]
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