homepage Welcome to WebmasterWorld Guest from 23.23.22.200
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
How to reload the parent frame
Rain_Lover




msg:4634415
 1:56 pm on Jan 1, 2014 (gmt 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:
[url]https://googledrive.com/host/0B5jOXzxlxbMhYVF3b0lubjlDWm8/parent.html[/url]


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?

 

daveVk




msg:4635003
 5:54 am on Jan 4, 2014 (gmt 0)

I think security is stopping you (same domain policy) try with both on googledrive or dropboxusercontent.

Rain_Lover




msg:4635026
 8:26 am on Jan 4, 2014 (gmt 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>

GoNC




msg:4641394
 2:11 am on Jan 31, 2014 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved