设置父位置的目的是什么
what's the purpose to set the parent location?
我在页面中嵌入了一个iframe。为什么我们需要从 iframe 设置永久位置 Href,有什么原因吗?
self.parent.location.href = blah blah blah;
这通常是一种断帧技术。
通常是这样的:
if(self != top)top.location.href=someUrl;
由于可以在页面正文中放置 iframe 标记,因此您可以使用 top
来操作主窗口。看:
主页
<!--This is the main page-->
<html>
<head>
<script>
alert(window.top.location.href);//The main page's URL
alert(window.self.location.href);//The main page's URL
alert(window.top.location.href);//The main page's URL
</script>
</head>
<body>
<iframe src="myFrame.html"></iframe>
</body>
</html>
我的框架.html
<html>
<head>
<script>
alert(window.location.href);//"myFrame.html"
alert(window.self.location.href);//"myFrame.html"
alert(window.top.location.href);//The main page's URL
</script>
</head>
<body>
</body>
</html>
相关文章:
- 将Rails后端添加到JS/HTML/CSS应用程序时,正确的文件位置是什么
- 几何位置的参数格式是什么
- RxJS在JS生态系统和演进中的位置是什么?
- 设置父位置的目的是什么
- js中php的标头位置的最佳替代品是什么
- 定义位置对象和URL参数的正确URL语法是什么
- 页面根上的位置.hash的条件是什么
- 使用svg.js设置位置动画的正确方法是什么
- Gridster.js中更新瓦片位置的算法是什么
- 获得网站访问者位置的最佳方法是什么?
- x和y的位置是什么?
- 在Angular/Django SPA中存放ng模板的最佳位置是什么?
- node.js包的正确位置是什么?
- 在文档中放置JavaScript/Ajax的最佳位置是什么?
- 在Google Earth中动态更新数千个位置标记的最佳方法是什么?
- 为什么IE's插入符在文本输入中的位置不等于字符串索引?解决方法是什么?
- iOS上Chrome中"不支持"的Facebook OAuth重定向方法的正确位置是什么
- 处理HTML5位置的最佳JQuery插件是什么
- Meteor:重定向后的最终位置/URL是什么
- 在 javascript 回调中错误参数的更正确位置是什么