Welcome to WebmasterWorld Guest from 54.160.198.60

Forum Moderators: open

Message Too Old, No Replies

How to reload the parent frame

     
1:56 pm on Jan 1, 2014 (gmt 0)

Junior Member

5+ Year Member Top Contributors Of The Month

joined:Mar 1, 2010
posts: 194
votes: 0


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>


See it in action:
[googledrive.com ]


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>


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?
5:54 am on Jan 4, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
posts:1585
votes: 0


I think security is stopping you (same domain policy) try with both on googledrive or dropboxusercontent.
8:26 am on Jan 4, 2014 (gmt 0)

Junior Member

5+ Year Member Top Contributors Of The Month

joined:Mar 1, 2010
posts: 194
votes: 0


I cannot put both frames on the same server.
For now I have found a workaround: document.referrer

Child:

<!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>
2:11 am on Jan 31, 2014 (gmt 0)

Junior Member

joined:Jan 9, 2014
posts: 150
votes: 0


FWIW, I think that Dave is right on this being a security issue. You're trying to get one website to refresh another, which usually isn't going to work.

If your workaround is working now, I wouldn't be surprised if it's not working on all browsers, or if it stops working in the next couple of browser updates. So don't rely on that too much.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members