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”,不能完全实现我想要的效果。

解决方案 »

  1.   

    若URL为http;//localhost/test.aspx,自动加上TARGET=“main"
      

  2.   

    若URL为http;//localhost/test.aspx,自动加上TARGET=“main"
    --------------------能说清楚点吗?不是很理解
      

  3.   

    if (self!=top) top.location.href = self.location.href这个貌似会跳出框架页的框架是套不住的
      

  4.   

    在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" />这个思路应该能实现你的要求,具体怎么方便你就怎么写吧
      

  5.   

    要这么麻烦吗?
    test.aspx页面后台加上
     protected void Page_Load(object sender, EventArgs e)
        {
            //if (!Page.IsPostBack)
            //{
               
                Response.Redirect("index.aspx");
           // }
        }
      

  6.   

    lynn_wang(迷途的小書童) ( ) 信誉:100  2007-08-03 08:28:35  得分: 0  
     
     
       問題已解決,幫頂&&學習ing  
     
    ————————————————————————试了,treble_h() 的方法可以实现。非常感谢!
    等会就结帖。
      

  7.   

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

  8.   

    treble_h() 已经说得很清楚了啊。不过还是贴出来吧:test.aspx:
    <script type="text/javascript">   
    <!--
    if (self==top) location.href = "index.aspx?redirectUrl="+location.href
    //   -->   
    </script> index.aspx:
    <frame name="mFrm" src="<%=Request.QueryString["redirectUrl"]==null?"main.aspx":Request.QueryString["redirectUrl"].ToString()%>" scrolling="no" frameborder="1" />