0

I get one page inside frame which intends to redirect users to another web site. However, only the the page inside the frame get changed to another web site.

What kind of measure can I use to redirect whole doucment to another web site?

Thank you!

Ricky
  • 34,377
  • 39
  • 91
  • 131

2 Answers2

4

When your page is inside an iframe, the Response.Redirect is only redirect the same page, that is in the iframe, not the parent one - one workaround is to register a javascript call, that can "say" to the parent window to redirect.

For example, you can do that:

ClientScript.RegisterStartupScript(this.GetType(), "scriptid", 
           "window.parent.location.href='redirectpage.aspx'", true);

at code behind to redirect the parent window to a new location.

The same way you can call this script from any javascript code to say to the top window to redirect.

top.location.href = "redirect.aspx" ;

reference: asp.net forum,
How to prevent IFRAME from redirecting top-level window

Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • what does the "scriptid" represent? Is that just the name of the given ClientScript process that we are looking at? or is that name being referenced somewhere else? I'm assuming this goes into a conditional statement within a .cs file, right? Thanks for your solution by the way! – klewis Apr 12 '13 at 15:43
  • 1
    @blachawk The scriptid is just a random name that go together with the script. ClientScript check that name and avoid to add the same id more than one time. – Aristos Apr 12 '13 at 16:58
-1

in Asp.net just use:

        Response.Redirect("webpagename.aspx");
joseph
  • 1