日期:2014-05-20  浏览次数:20881 次

框架嵌入网址后,会自动跳转,怎么解决
C# code

<body scroll="no" style="overflow-y:hidden">
    <form id="form1" runat="server">
    <div>
    <!--第一层,用户信息,时间信息-->
     <div  id="time" style="border:1px; color:black; height:100px; text-align:center; font-size:18px">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        
            <asp:UpdatePanel ID="upWebSite" runat="server">
            <ContentTemplate>
               <table style="width:1024px"><tr>
               <td style="width:200px;"></td>
               <td style="width:400px; padding:10px;">               
顶部信息
</td>
               <td> <asp:Panel ID="pnContent" runat="server">
              
                      <asp:HyperLink ID="hplkNewSite" Target="_blank" runat="server"  CssClass="newWindow">在新窗口打开</asp:HyperLink>
               </asp:Panel></td>
               <td></td>
               </tr></table>
            </ContentTemplate>
            </asp:UpdatePanel>
           </div>
           <!--第二层,信息-->
         
         

<table id="ontable">
<tr>
<td id="tdon" style="width: 100%">

<iframe id="framev" name="framev" src="http://www.ads4cn.com/newsbar/refferer.asp" style="width: 100%; border: 0px; margin: 0px; padding: 0px;"></iframe>
</td>

</tr>
</table>


    </div>
    </form>
</body>




为什么,我放入其他的网址。。。比如百度之类的,,就不会自动跳转,,


例如:我浏览的地址是http://localhost:3512/WebURL.aspx
框架是<iframe id="framev" name="framev" src="http://www.baidu.com" style="width: 100%; border: 0px; margin: 0px; padding: 0px;"></iframe>
这样就没问题。。


如果框架的网址变为这个<iframe id="framev" name="framev" src="http://www.ads4cn.com/newsbar/refferer.asp" style="width: 100%; border: 0px; margin: 0px; padding: 0px;"></iframe>


就直接不是localhost,而是http://www.ads4cn.com/newsbar/refferer.asp这个地址了,,,

怎么解决???





------解决方案--------------------
他有判断顶部

比如 if(window.top.location.href!=window.location.href){
//看你iframe我 我跳我跳我跳出来
window.top.location.href=window.location.href
}
------解决方案--------------------
if(window.top.location.href!=window.location.href){
//看你iframe我 我跳我跳我跳出来
window.top.location.href=window.location.href
}
------解决方案--------------------
不能完全屏蔽的,毕竟你是嵌入别人的网站,
一般的做法是在外面的页面中写
location=null
或者
location=""

但这对于防止嵌入的页面是不能实现的