Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Nov 2009
    Posts
    195
    Thanks
    22
    Thanked 0 Times in 0 Posts

    How to reload the parent frame

    Sample parent code:

    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:
    https://googledrive.com/host/0B5jOXz...m8/parent.html


    Sample child code:

    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?

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    966
    Thanks
    19
    Thanked 211 Times in 209 Posts
    Browser security is preventing you.
    Same origin policy is to blame.

    https://developer.mozilla.org/en-US/...for_JavaScript

    If you host both documents
    (parent and child) on the
    same server you will have
    no problemsw.
    Last edited by DaveyErwin; 01-01-2014 at 03:22 PM.

  • #3
    New Coder
    Join Date
    Nov 2013
    Location
    UK
    Posts
    42
    Thanks
    6
    Thanked 1 Time in 1 Post
    Hi
    In my website I had the same problem. I solved it by "clicking" a fake button on the parent page, which triggered the reload. And was working . If you want to know more, let me know.

  • #4
    Regular Coder
    Join Date
    Nov 2009
    Posts
    195
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oceansoul1976 View Post
    Hi
    In my website I had the same problem. I solved it by "clicking" a fake button on the parent page, which triggered the reload. And was working . If you want to know more, let me know.
    Please share with us what you have. Thanks!

  • #5
    New Coder
    Join Date
    Nov 2013
    Location
    UK
    Posts
    42
    Thanks
    6
    Thanked 1 Time in 1 Post
    The way I see it is the browser won't let you refresh other window or frame except the current frame (the one from where is called from). My workaround was with a fake button - but is much simpler with a procedure (let's call it "reloaded()" which will be in the parent frame, and in which you'll have the refresh (window.location.reload(true) ).
    Then, from your child frame, all you'll have to do is to call the procedure ( ...onclick="parent.reloaded()" ).
    Sorry the code is not arranged properly, I'm pretty new to this forum and I don't know all the "chords" yet.
    I will test this method again, just to be sure.
    Good luck,
    Dorin
    www.windows-addict.com

  • #6
    New Coder
    Join Date
    Nov 2013
    Location
    UK
    Posts
    42
    Thanks
    6
    Thanked 1 Time in 1 Post
    Yeap....tested in IE and FireFox....working like a charm....
    Let me know if it helped.

    P.S.: Happy New Year

  • #7
    Regular Coder
    Join Date
    Nov 2009
    Posts
    195
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oceansoul1976 View Post
    Yeap....tested in IE and FireFox....working like a charm....
    Let me know if it helped.

    P.S.: Happy New Year
    Thanks for the answer and happy new year!
    Actually in my real site I cannot use your solution. Thanks anyway!

  • #8
    New Coder
    Join Date
    Nov 2013
    Location
    UK
    Posts
    42
    Thanks
    6
    Thanked 1 Time in 1 Post
    why ? what happens ?

  • #9
    Regular Coder
    Join Date
    Nov 2009
    Posts
    195
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oceansoul1976 View Post
    why ? what happens ?
    My site is created on Google Sites and as you probably know Google Sites doesn't support JavaScript.

  • #10
    New Coder
    Join Date
    Nov 2013
    Location
    UK
    Posts
    42
    Thanks
    6
    Thanked 1 Time in 1 Post
    Tell you the truth, I didn't know that. Sorry


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •