ASP.NET如何从一个页面重定向到另一个网站的框架内 [英] ASP.NET How to redirect to another web site from a page inside a frame

查看:86
本文介绍了ASP.NET如何从一个页面重定向到另一个网站的框架内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个页面内帧,它打算将用户重定向到另一个网站。但是,只有在框架内的页面得到改变到另一个网站。

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.

我可以使用什么样的措施来全doucment重定向到另一个网址?

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

感谢您!

推荐答案

在你的网页是一个iframe里面,的Response.Redirect 只重定向相同的页面,那是在iframe,而不是父一 - 一个解决办法是注册一个JavaScript调用,能说父窗口重定向。

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.

例如,你可以这样做:

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

在code背后到父窗口重定向到一个新的位置。

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

您可以从任何JavaScript code调用此脚本以同样的方式说顶端窗口重定向。

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" ;

参考: asp.net论坛,结果
<一href=\"http://stackoverflow.com/questions/369498/how-to-$p$pvent-iframe-from-redirecting-top-level-window\">How从重定向prevent IFRAME顶层窗口

这篇关于ASP.NET如何从一个页面重定向到另一个网站的框架内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆