Results 1 to 7 of 7

Thread: Refresh Calling page

  1. #1
    Join Date
    Nov 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Refresh Calling page

    1) Script Title: DHTML Window Widget

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...ndow/index.htm

    3) Describe problem:

    script works beautifully !!

    but, i want to refresh the page that called the window after the window is closed.

    what i'm looking for is this chain of events:

    Parent Page loads which has link that uses the Window Widget...
    click on link, window opens, data form presented, user inputs data, done with that page - close window,
    after the window closes I want the page that called it to refresh since there were probably some updates made in the window (via a form) that affect the list of data on the calling page.

    I tried doing this in the dhtmlwindow.onclose() event - but i think it was erroring out since i was asking for a window.location.reload() while it was closing.

    Does anyone know how to call a simple function after the DHTML Window has close. Is there an after close event that can be captured.

    thanks
    kevin

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    window.opener.reload() perhaps?
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Nov 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    tried that in place of the return window.confirm("Close this window?") but, it didn't seem to work

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If the code is on the page that you want reloaded:

    Code:
    setTimeout(function(){window.location.reload(true);},100);
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Nov 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Can you tell me how/where that fits the script which structure is like this:
    ( loose syntax here)

    function mywindowopener()
    myvar=dhtmlwindow.open( 'w2','ajax' ...my parameters...)
    myvar.onclose=function(){
    ....function statements go here ....
    }

    if your intent was to refresh the page every x seconds, that won't work - refreshes seem to close the child windows

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    function mywindowopener()
    myvar=dhtmlwindow.open( 'w2','ajax' ...my parameters...)
    myvar.onclose=function(){
    setTimeout(function(){window.location.reload(true);},100);
    }
    setTimeout only executes once, but is delayed. I think you are confusing this with setInterval. Even setInterval would work here, as once a page is refreshed, the interval ends.

    However, if you want to reload the page, yes that will return it to its normal first load state, except that any server side and javascript cookie data that the page is configured to respond to, if any of that has been updated, the page will now respond to that updated data.

    But that will only reload the page that this code is on. If you want to reload another page, you must have a reference to it, and you must execute its refresh before the page that is refreshing its window closes.

    So, you might want to have:

    Code:
    function mywindowopener()
    myvar=dhtmlwindow.open( 'w2','ajax' ...my parameters...)
    myvar.onclose=function(){
    window.opener.location.reload(true);
    setTimeout(function(){window.close();},100);
    }
    It's a little confusing because I'm not clear on what type of window(s) you are referring to, actual and/or virtual, or where the code is and what window object(s) it is supposed to do what to.

    If you need more help:

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    To understand the relationship between actual windows in this regard, try these two pages:

    test.htm:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    window.onload=function(){alert('I\'ve just Loaded!');};
    </script>
    </head>
    <body>
    Test HTML Content<br>
    <a href="test_closed.htm" onclick="window.open(this.href,'_blank');return false;">TC</a>
    </body>
    </html>
    test_closed.htm

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    window.onload=function(){
    window.opener.location.reload(true);
    setTimeout(function(){window.opener.document.body.style.backgroundColor='pink';},200);
    setTimeout(function(){window.close();},500);
    }
    </script>
    </head>
    <body>
    
    </body>
    </html>
    Opening test.htm will fire its onload alert.

    Clicking on the link TC will open test_closed.htm in a new window, which will:

    1. reload test.htm, firing test.htm's onload alert
    2. turn test.htm's background pink
    3. close itself (test_closed)
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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