日期:2014-05-17 浏览次数:20567 次
<script language="javascript" type="text/javascript">
if (window.self != window.top) {
window.top.location = window.location;
}
</script>
------解决方案--------------------
有a.aspx页面,<iframe>中是b.aspx页面,
则在b.aspx页面的Page_Load中:
if (Request.ServerVariables["HTTP_REFERER"] == null)
{
Response.Redirect("a.aspx");
}
else
{
string urlPre1 = "http://" + Request.ServerVariables["HTTP_HOST"].ToString();
string urlPre2= Request.ServerVariables["SCRIPT_NAME"].ToString();
urlPre2 = urlPre2.Substring(0, urlPre2.Length - 6)+"a.aspx";//注意-6是b.aspx的长度
if (urlPre1 + urlPre2 != Request.ServerVariables["HTTP_REFERER"].ToString())
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "window.open('a.aspx')", true);
}