使用javascript或Jquery从iFrame重定向
如果一个网站被加载到一个iframe中,我需要在该iframe的子页面上放置什么代码才能脱离该iframe并将该页面作为顶部文档加载或重新加载到该页面 刚找到密码使用javascript或Jquery从iFrame重定向,javascript,jquery,html,Javascript,Jquery,Html,如果一个网站被加载到一个iframe中,我需要在该iframe的子页面上放置什么代码才能脱离该iframe并将该页面作为顶部文档加载或重新加载到该页面 刚找到密码 <script> if(window.top !== window.self){ window.top.location.href = "http://www.blah.com"; } </script> if(window.top!==window.self){ window.top.location.
<script>
if(window.top !== window.self){
window.top.location.href = "http://www.blah.com";
}
</script>
if(window.top!==window.self){
window.top.location.href=”http://www.blah.com";
}
更好的代码:
<style> html{display : none ; } </style>
<script>
if( self == top ) {
document.documentElement.style.display = 'block' ;
} else {
top.location = self.location ;
}
</script>
html{display:none;}
if(self==顶部){
document.documentElement.style.display='block';
}否则{
top.location=self.location;
}
代码示例如下:
<!DOCTYPE html>
<html lang="en">
<head>
blah
</head>
<body>
<iframe src="www.blah.com"></iframe>
</body>
</html>
废话
我需要在www.blah.com(在本例中)上添加什么JQuery或javascript,使其脱离iframe并直接向用户显示www.blah.com?这应该可以:-
<script type="text/javascript">
if (window!=top){top.location.href=location.href;}
</script>
如果(window!=top){top.location.href=location.href;}
这应该可以:-
<script type="text/javascript">
if (window!=top){top.location.href=location.href;}
</script>
如果(window!=top){top.location.href=location.href;}
如本文所述(有更充分的解释):
如本文所述(有更充分的解释):
你要找的东西叫做 下面是该文章中建议的实现:
<style> html{display : none ; } </style>
<script>
if( self == top ) {
document.documentElement.style.display = 'block' ;
} else {
top.location = self.location ;
}
</script>
html{display:none;}
if(self==顶部){
document.documentElement.style.display='block';
}否则{
top.location=self.location;
}
你要找的东西叫做
下面是该文章中建议的实现:
<style> html{display : none ; } </style>
<script>
if( self == top ) {
document.documentElement.style.display = 'block' ;
} else {
top.location = self.location ;
}
</script>
html{display:none;}
if(self==顶部){
document.documentElement.style.display='block';
}否则{
top.location=self.location;
}
如果您使用链接设置目标=“\u top”属性可能会执行此任务。如果您使用链接设置目标=“\u top”属性可能会执行此任务。这将如何脱离iframe?这需要单击iframe子页面上的链接。谢谢,但那不是我想要的,那怎么会从一个iframe中爆发出来呢?这需要单击iframe子页面上的链接。谢谢,但那不是我想要的