PDA

View Full Version : main browser page location via pop up


ric_iceman
09-17-2001, 10:37 AM
Normally chilled out but getting a little hot under the collar with this one.
I've got a main page in the broswer window which consists of 3 frames.
On the main content frame is a link that generates a pop up window.
On the pop up window is a link, which when clicked, will close the pop up and set the target of the main frame to a different page from the one currently being displayed.
I've got the pop up window to close (no big deal there) but can't change the location of the main frame on the page.

Thanks and pints in advance.
Rich

PCheese
09-17-2001, 10:53 AM
Erm, as a quick guess,

onClick="javascript: parent.frames['main'].location='clickedonURL.htm';"

ric_iceman
09-17-2001, 11:28 AM
No luck with that one.

I've got a javascript:window.close() for the text link in the pop up and also in the body tag I've put an onClose=event() where event() =
parent.frames['main'].location='../index.html'

The pop up closes but the main frame in the browser is unchanged

Any other thoughts ???

PCheese
09-17-2001, 11:33 AM
Hmm, you could try stepping through the frames by number so it's parent.frames(1).location etc.

Just to check if it will update any of the frames. Other than that, my limited knowledge has left the building.

ric_iceman
09-17-2001, 11:49 AM
Cheers for your thoughts PCheese but .........
no luck with that either.

ANy other thoughts out there folks ........

scoutt
09-17-2001, 11:55 AM
have you tried to load the page first then close the window?

ric_iceman
09-17-2001, 12:09 PM
Have tried to change the page before closing.

Even though I am using the notation as suggested in previous mailings, the pop up window is itself trying to find the new page specified, rather than the main window.
Nearly there i guess.

_mrkite
09-17-2001, 11:40 PM
<a href="javascript:opener.location=' url ';self.close()">

parent is a frame-to-frame reference - a popup window is not part of a frameset. opener references the window object - possibly a frame - that ( surprise!) opened the window it is used in.

You might want to put the script in a function so it can be called if the user - they're like this you know - closes the popup by other means:

<script language="JavaScript" type="text/javascript">

function adios() {
opener.location=' other page ';self.close();
}

window.onunload = adios;

</script>

and assign the hyperlink as well...

ric_iceman
09-18-2001, 05:09 AM
Thanks _mrkite, certainly seems to have done the trick apart from one bit.

I have :-
<script>
function frameNavig() {
opener.location='../control/over.html';self.close();
}
window.onunload=frameNavig();
</script>

as the function, and have :-
<a href="#" onClick="frameNavig();"><b>here </b></a>

as the clickable link.

However, the pop up window comes up and then disappears straight away without displaying its page. So I can't even click on it as it doesn't stay on the screen.
The main window is populating though which is cool.

Any last thoughts guys ????

Dr. Web
09-18-2001, 02:03 PM
your function just tells the main window to change its page, and it tells the pop-up to close. If you want the pop-up to stay, nix the self.close()

_mrkite
09-18-2001, 05:02 PM
ric_iceman -

There's a reason why I did this:

window.onunload = adios;

and not this:

window.onunload = adios();

The former assigns the function adios to the onunload handler (to be run when an unload event is fired); the latter calls the function immediately; the parentheses (instance) aren't just for holding arguments...

http://wsabstract.com/javatutors/error2.shtml

For my next tip: http://www.oreilly.com/catalog/jscript3/reviews.html :cool: