在iframe中如何操作父窗地址
在iframe中怎么操作父窗地址
1.html
2.html
比如现在浏览1.html地址为 http://127.0.0.1/1.html
在2.html中为父窗地址(追加/删除)一些内容例如?add 或则 #add
最终如下
http://127.0.0.1/1.html?add
http://127.0.0.1/1.html#add
------解决方案--------------------
window.top.location.href=window.top.location.href+"?add=...."
试试
------解决方案--------------------
top 顶层引用
parent 父级引用
------解决方案--------------------
不要设置?add,页面会刷新,当然如果是你想要的你可以设置
1.html
<html>
<head>
</head>
<title>1.html</title>
<body style="background:darkblue">
<iframe src="2.html" frameborder="0" width="100%" height="600" scrolling="auto"></iframe>
<p style="background:yellow;">0123456789</p>
</body>
</html>
2.html
<html>
<head>
</head>
<title>2.html</title>
<body style="background:white">
<p style="background:red;">9876543210</p>
</body>
</html>
比如现在浏览1.html地址为 http://127.0.0.1/1.html
在2.html中为父窗地址(追加/删除)一些内容例如?add 或则 #add
最终如下
http://127.0.0.1/1.html?add
http://127.0.0.1/1.html#add
------解决方案--------------------
window.top.location.href=window.top.location.href+"?add=...."
试试
------解决方案--------------------
top 顶层引用
parent 父级引用
------解决方案--------------------
parent.hash='#add'
不要设置?add,页面会刷新,当然如果是你想要的你可以设置