Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-04-2013, 02:16 PM   PM User | #1
darrylw99
New to the CF scene

 
Join Date: Feb 2012
Location: Northwich, Cheshire
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
darrylw99 is an unknown quantity at this point
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?
darrylw99 is offline   Reply With Quote
Old 01-04-2013, 02:19 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 952
Thanks: 7
Thanked 98 Times in 98 Posts
WolfShade is an unknown quantity at this point
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".
WolfShade is offline   Reply With Quote
Old 01-09-2013, 01:09 AM   PM User | #3
sbhmf
New Coder

 
Join Date: Jan 2013
Location: Sunnyvale, CA
Posts: 40
Thanks: 3
Thanked 1 Time in 1 Post
sbhmf is an unknown quantity at this point
before closing the child window, execute opener.location.href = <the url and querystring of the parent page>
sbhmf is offline   Reply With Quote
Old 01-09-2013, 09:31 AM   PM User | #4
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,469
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
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 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me is offline   Reply With Quote
Old 01-09-2013, 09:35 PM   PM User | #5
sbhmf
New Coder

 
Join Date: Jan 2013
Location: Sunnyvale, CA
Posts: 40
Thanks: 3
Thanked 1 Time in 1 Post
sbhmf is an unknown quantity at this point
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.
sbhmf is offline   Reply With Quote
Reply

Bookmarks

Tags
window.opener refresh

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:01 PM.


Advertisement
Log in to turn off these ads.