CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   DOM and JSON scripting (http://www.codingforums.com/forumdisplay.php?f=15)
-   -   Window.opener refresh/reload (http://www.codingforums.com/showthread.php?t=285269)

darrylw99 01-04-2013 02:16 PM

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?

WolfShade 01-04-2013 02:19 PM

If you close the window before the reload, the reload won't process.

sbhmf 01-09-2013 01:09 AM

before closing the child window, execute opener.location.href = <the url and querystring of the parent page>

rnd me 01-09-2013 09:31 AM

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()" ... >

sbhmf 01-09-2013 09:35 PM

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.


All times are GMT +1. The time now is 10:21 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.