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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Location
    Northwich, Cheshire
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Window.opener refresh/reload

    I have a page (index.asp) that lists entries from a database.

    This page then opens another Window (using javascript). This then adds another record to the database (filename is addJob.asp).

    What I need to do is Close this window BUT refresh the opener (index.asp) which will show the newly inserted record.

    Ive managed to get the following working on index.asp
    javascript:window.close();window.parent.document.location.reload(true);

    but not on addjob.asp.

    Any suggestions?

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    If you close the window before the reload, the reload won't process.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    Regular Coder
    Join Date
    Jan 2013
    Location
    Sunnyvale, CA
    Posts
    115
    Thanks
    8
    Thanked 7 Times in 7 Posts
    before closing the child window, execute opener.location.href = <the url and querystring of the parent page>

  • #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,374
    Thanks
    11
    Thanked 592 Times in 572 Posts
    it's easily doable and you don't need gimmicks like url matching to do it.

    post the popup code and i can help specifically, but in general, there's only one snag to doing this easily: you need to call popup.close() from the opening page.

    you can do an onsubmit event on your popup's form that calls a function on opener that
    1. popup.close()es the data entry form
    2. reloads itself (location.href=location.href)

    maybe something like this:

    on the opening page:
    Code:
    var popup=window.open("page2");
    self.finish=function(){
      setTimeout(function(){ 
         popup.close();
         location.href=location.href;
      }, 500);
    }
    and on the popup page:
    Code:
    <form onsubmit="opener.finish()" ... >
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%

  • #5
    Regular Coder
    Join Date
    Jan 2013
    Location
    Sunnyvale, CA
    Posts
    115
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Good point about the URL-matching, it is not necessary if parent is reloading the same url.

    So if you want to let the child window manage itself independently, then the child can simply execute:

    opener.location.href = opener.location.href; self.close();

    less complicated than the self.finish function and modifying onsubmit.


  •  

    Tags for this Thread

    Posting Permissions

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