日期:2014-05-18  浏览次数:20428 次

页面只能在框架内打开的问题,顶者有分
1、VS2005。

2、框架页   /index.aspx,其中有:
<frame   name= "mFrm "   src= "/main.aspx "   scrolling= "no "   frameborder= "1 "   />

3、存在网页   /test.aspx。

4、想要的效果:
没在框架内打开网页(例如在浏览器地址栏中输入http;//localhost/test.aspx)时,自动转到   /index.aspx,并且,设置上述   "mFrm "   的   src   为   /test.aspx。

5、查网上,在   /test.aspx   中用脚本“if   (self!=top)   top.location.href   =   self.location.href”,不能完全实现我想要的效果。


------解决方案--------------------
up
------解决方案--------------------
新手,框架的东西也不懂,
等着 学习
------解决方案--------------------
这个问题不是很懂,
学习一下

------解决方案--------------------
若URL为http;//localhost/test.aspx,自动加上TARGET=“main "
------解决方案--------------------
if (self!=top) top.location.href = self.location.href

这个貌似会跳出框架页的

框架是套不住的
------解决方案--------------------
在test.aspx
if (self==top) location.href = "index.aspx?redirectUrl= "+location.href

在index.aspx
<frame name= "mFrm " src= " <%=Request.QueryString[ "redirectUrl "]==null? "main.aspx ":Request.QueryString[ "redirectUrl "].ToString()%> " scrolling= "no " frameborder= "1 " />

这个思路应该能实现你的要求,具体怎么方便你就怎么写吧
------解决方案--------------------
就楼上的啦
------解决方案--------------------
要这么麻烦吗?
test.aspx页面后台加上
protected void Page_Load(object sender, EventArgs e)
{
//if (!Page.IsPostBack)
//{

Response.Redirect( "index.aspx ");
// }
}
------解决方案--------------------
UP

------解决方案--------------------
問題已解決,幫頂&&學習ing

------解决方案--------------------
解决方法如和:贴出来看看
在head中添加
<base target= "_self "/>
window.onload=function()
{
parent.mFrm.location.href= "test.aspx ";
}

没试!