Javascript 如何重新加载父帧

Javascript 如何重新加载父帧,javascript,jquery,html,iframe,Javascript,Jquery,Html,Iframe,示例父代码: <!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">

示例父代码:

<!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>
等等


我遗漏了什么?正确的方法是什么?

如果您在chrome浏览器控制台中检查,它会显示附加错误,即跨域访问问题

有关详细信息,请参阅错误屏幕抓取


查看它对您的帮助。

我使用了以下代码来刷新iframe,而没有刷新您可以在代码中使用的“我的洞”页面:

<script type='text/javascript'>
    setTimeout(function()
    {
      location = 'https://dl.dropboxusercontent.com/u/4017788/Labs/child.html'
    },4000) // set time for refreshing iframe as you wish I used 4000 miliseconds
    </script>
你可以试试这个

 <script>
    function myFunction() {
     window.parent.location=window.parent.location;
    }
    </script>

刚刚找到我问题的答案:document.referer

儿童:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Child</title>
</head>
<body>
<button onclick="myFunction();">Try it!</button>
<script>
function myFunction() {
window.parent.location = document.referrer;
}
</script>
</body>
</html>

我不清楚这个问题…@Jai:当我点击按钮时,整个页面的父框架不会刷新。如果你能发布点击事件代码,那么window.parent.location=window.parent.location;工作?@OneOfOne:恐怕不行。我需要重新加载父/整个页面,而不是iframe。然后在location=“here will your page url”之后只加载页面url。这在我的情况下是不可能的,因为父url是动态的-它不是一个固定的url,你可以依赖。我实际上已经尝试过了,它工作正常。。我可以知道你得到了什么结果吗?你如何确定你的父页面是否重新加载了,因为现在你的父页面中除了框架之外还有其他数据
 <script>
    function myFunction() {
     window.parent.location=window.parent.location;
    }
    </script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Child</title>
</head>
<body>
<button onclick="myFunction();">Try it!</button>
<script>
function myFunction() {
window.parent.location = document.referrer;
}
</script>
</body>
</html>