如何重新加载父框架 [英] How to reload the parent frame
本文介绍了如何重新加载父框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
示例父代码:
Sample parent code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Parent</title>
</head>
<body>
<iframe src="https://dl.dropboxusercontent.com/u/4017788/Labs/child.html" width="200" height="100"></iframe>
</body>
</html>
请参阅操作:
https://googledrive.com/host/0B5jOXzxlxbMhYVF3b0lubjlDWm8/parent.html
示例子代码:
See it in action:
https://googledrive.com/host/0B5jOXzxlxbMhYVF3b0lubjlDWm8/parent.html
Sample child code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Child</title>
</head>
<body>
<button onclick="myFunction();">Try it!</button>
<script>
function myFunction() {
parent.location.reload();
}
</script>
</body>
</html>
我尝试了类似问题中提供的许多方法无济于事,例如:
window.parent.location.reload();
top.location.reload();
等
我缺少什么什么是正确的方法?
I have tried many methods offered in similar questions to no avail, such as:
window.parent.location.reload();
top.location.reload();
etc.
What am I missing and what's the right approach?
推荐答案
您可以尝试我的提示与跨域IFrame的通信 - 跨浏览器解决方案 [ ^ ]。
您可以使用window.postMessage
的方法与子页面的父页面进行通信,反之亦然。
You can try my tip for Communication with Cross Domain IFrame - A Cross Browser Solution[^].
You can use the method ofwindow.postMessage
to communicate with parent page from child or vice versa.
这篇关于如何重新加载父框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文