Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Javascript: Reloading contents in main browser window from another?

Javascript: Reloading contents in main browser window from another?
Thread Tools
Dedicated MacNNer
Join Date: Nov 2000
Location: Baltimore, MD
Status: Offline
Reply With Quote
Apr 22, 2003, 11:18 AM
 
Hey folks -

Have a little stumbling block in some web development I'm doing using PHP and MySQL. Javascript has never been my strong point, and what documentation I've been able to find isn't doing me any good. I have a case where, using JavaScript, I pop open a new window where a user can do some manipulation of data in the database that would cause the content of the main browser window to change, so I wish to force the main browser window to reload after the user performs the data manipulation in the popup window. I know that by default, the main browser window has no "name", so I use this snippet of code to give it a name:

window.name = 'MainWindow';

In the popup window, once the user manipulates the data, I try to pull one of these to reload the main browser window:

MainWindow.location.reload();

But, nothing happens. I'm sure I'm missing something basic, but I haven't been able to find anything on the web that deals with refreshing the main browser window from a spawned pop-up, only vise versa.

Thanks in advance!
The Quintessential Featherhead.
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Apr 22, 2003, 11:41 AM
 
You could just set a reference in the popup Window to the main window. In the main window do something like this:


Code:
var popupWin = window.open (url,name,widgets); popWin.parentWindow = self;
Then, in your popup window, you can do:

Code:
self.parentWindow.doSomething();
This is untested, but it should work.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Nyuni  (op)
Dedicated MacNNer
Join Date: Nov 2000
Location: Baltimore, MD
Status: Offline
Reply With Quote
Apr 22, 2003, 12:08 PM
 
Okay, tried that, and still no reload of the main window.

Here's the code in the main window's HTML:
nested in the HEAD tag of the page, I have:

(Edit: UBB seemed to not display the code properly. )

Basically, I define a new function to pop the window, then from a link onClick I call the function to pop the window, the function includes the code you provided above. The window pops, but still no reload after the user does theri data manipulation.
(Last edited by Nyuni; Apr 22, 2003 at 12:16 PM. )
The Quintessential Featherhead.
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:26 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2