0

I have a javascript that makes a iframe in a blogger and shows a html page that's in a different domain, and there is a button/image in the HTML page. and when someone clicks the button I need to redirect the parent page to another website.

is there a way I can do it?

top.location.href=

is not working.

rksh
  • 3,920
  • 10
  • 49
  • 68
  • You forgot window... http://stackoverflow.com/questions/580669/redirect-parent-window-from-an-iframe-action-using-javascript – Breezer Sep 12 '12 at 07:02
  • @Breezer — There is no need to mention the default object explicitly unless `top` is being masked in the local scope. – Quentin Sep 12 '12 at 07:04

1 Answers1

1
top.location = ...

You can't access the properties of location, but you can overwrite the whole thing.

Alternatively, just use a link:

<a href="foo" target="_top">
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • I think the problem is in that the iframe and the blog are on the same domain, i can't use href because I do not want to show the link being redirected to – rksh Sep 12 '12 at 07:41
  • 1
    The user is going to know where they get redirected to eventually. It isn't something you can keep secret. – Quentin Sep 12 '12 at 08:44