Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

location.reload()

Status
Not open for further replies.

Masali

Programmer
Jun 19, 2002
143
0
0
SE
First, if I have two MSIE-windows open, is it possible to reload one of the windows using a javascript in the other window? In that case how?

Second, When I use location.reload() on a CGI-script with data POSTed to the script, I get a messagebox telling me that the page cannot be updated without sending the data-information again. Then I have to press Try again to refresh. Is there a way to override this messagebox, so I just have to use location.reload() and not needing to press Try again?

Thanks in advance!
 
you can provided one window opened the other using window.open(). That's mean one of the windows have to be the primary window and he other one the secondary window.

as for your last question, i dont think there is a way to override that dialog, else your script on that page would be working on empty data (if there is such a thing), since this page need the data to be submitted to it, to display the appropriate information.

does this make any sense? im beggining to doubt my english, hehehe. hope this helps u in any way other than confuse you more...


biggie
 
Hi, again

The problem is that I have one main-windows that is supposed to open the child-windows with windows.open, but then I want the child-window to be able to control the main-window using something like main.location.reload()

For my last question... The data that is sent with the script should be sent again, I just don't want the dialog to pop up.
 
in that case, use the
Code:
window.opener
construct of javascript, in the secondary window.
That should do the trick!



biggie
 
Hi again,

How should I use the window.opener? javascript is not my strong side... Please write a javascript-snippet of the code to refresh the mainpage and tell me how to access the main window. What is it called? I mean usually if you opened a window with window.open you access it using nameofwindow.location.reload(). But what is the name of the main-window and how do you set it?

Sorry to bother again..

Masali
 
ok, here's and example which can walk your way through:

to reload the main page:

window.opener.document.locatio.reload();

to access a form element in main page from secondary window:

VariableInThisWindow=window.opener.document.formName.formElementName.formElementNameValue;

there. I hope this clarifies things a bit!


biggie
 
Ahh, perfect!

Thanks alot!

Masali
 
Masali,

to refresh your opener from the child window without the prompt, give the Submit button in the opener an id, then click() the button from the child window:

in the main window (opener):
<input type=&quot;submit&quot; id=&quot;submitButton&quot; />

in the child window:
opener.document.forms[0].submitButton.click();
=========================================================
if (!succeed) try();
-jeff
 
It wasn't possible to do like you suggested in my script, but it gave me another idea that solved the problem. Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top