views:

713

answers:

3

I'm trying to convince a page that it is the window.top even though it is in an iframe.

In FF you can do

window.defineGetter('top', function() { return window});

in Webkit (Safari/Chrome) you can simply do

window.top = window

but in IE none of those methods work. Anyone done this before?

A: 

Try window.top = window.top.window

More details on DOM Window.

Mark Hurd
Unfortunately this doesn't work. The issue is that IE throws an error when trying to set window.top (or even window for that matter)
Dave
A: 

Setting window.top doesn't work. Its not allowed in IE.

I ended up having to make my own fake window object, fill it with most of the properties of the window object, and then making a fake .top property.

Dave
A: 

I'd maybe try using the "define getter" notation that John Resig uses in his article on the topic:

Window.prototype.__defineGetter__('top',function(){return this;});

JasonWyatt