0

Our website gives a widget to be installed in pages (a piece of Javascript that writes an iframe element and inside it renders things and you see rss, images, and other stuff).

I need, after the user do some stuff, to redirect the page (where the widget is) to another location, but using top.document.location is forbidden since the page and the iframe generated by the widget are in different location, and using window.open is usually blocked by popup blockers.

How can i do it ?

Matt
  • 14,353
  • 5
  • 53
  • 65
FlamingMoe
  • 2,709
  • 5
  • 39
  • 64

2 Answers2

0

Try:

window.location.href = "url"; 
The Mask
  • 17,007
  • 37
  • 111
  • 185
0

Although reading properties from the top window is disallowed, some of them are open to writing - and one of these are location.

Simply do

top.location = "http://foo/bar"; 

and it will redirect just fine.

Sean Kinsey
  • 37,689
  • 7
  • 52
  • 71
  • Thanks for the correction. [It certainly looks like you're right](http://stackoverflow.com/questions/952242/), but I can't find any reliable documentation on the write-only properties (e.g. MDC, W3C, Quirksmode, even Wikipedia). Do you have a link to more-or-less official documentation on this? – Matt Ball Mar 11 '11 at 14:26
  • @Matt, no this isn't covered by the W3 specs - it's rather an action allowed by the different browser vendors when they implemented Same Origin Policy (which isn't a part of any spec either). But `location` is the only such property (to allow navigation) (except for the 'bugs' related to frameElement in FF2 and window.opener in IE6-7). – Sean Kinsey Mar 11 '11 at 15:40