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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting another page to refresh

Status
Not open for further replies.

MrsKensington

Programmer
Sep 26, 2001
28
GB
My main page contains two form elements with the names "sideBar" and "main". in the main window when the user clicks on a link a new page opens up using window.open
This page is supposed to be an options page where you'll change some options in a form and then click "OK".
When "OK" is clicked I need to be able to refresh the "main" page.
Is there any way of doing this?
 
Hi MrsKensington,

Did you try something like this:

<input type=&quot;button&quot; value=&quot;OK&quot; name=&quot;OK&quot; onClick=&quot;reloadAndClose()&quot;>

function reloadAndClose() {
window.opener.location.reload();
window.close();
};

Hope this helps ...
 
great!

i modified the code (as its being called from a perl script) so it just prints this
Code:
<SCRIPT language=\&quot;JavaScript\&quot;>
    <!--
    window.opener.location.reload();
    -->
</SCRIPT>
and it worked!
one question how does it know which page to refresh or does it refresh all pages?
 
MrsKensington,

I don't really understand your last question but let me try to answer it:

The reload method forces a reload of the window's current document, i.e. the one contained in the Location.href property.
It behaves in exactly the same way as the browser's reload button which, by default reloads from the cache.

Hope this helps ...
 
yeah i just twigged that it wasn't doing exactly what i wanted.
When i click the &quot;OK&quot; button it does what i want as it refreshs then closes (which for whatever reason refreshs the &quot;main&quot; screen). But when i click my &quot;Apply&quot; button (which doesn't close the window) it refreshs the current window (obviously).
Is there any way i can specify which frame to refresh?
would changing the Location.href property work?
 
MrsKensington,

To specify which frame to refresh, try this:

window.opener.top.myFrame.location.reload();

For changing the Location.herf property, better is to try it 'cause I don't know if it will works.

Hope this helps ...
 
no actually ignore that. it is working i wasn't calling the correct function when the button was clicked. I think lunch is calling me! :)
 
lunch?
are you from France or near to it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top