View Full Version : how do you target to the top page?
reptilemart
09-24-2002, 10:55 AM
Hello,
Sorry for the poorly worded title.. I couldn't think of another way to put it.
I have these lines of code:
var action=function()
{
document.location.href="http://members.optushome.com.au/roeleven/Undercon/main.html";
}
How do i get it to target the link to the top page (get out of the frameset)? In html i would do it like this:
<a href="http://members.optushome.com.au/roeleven/Undercon/main.html" target=_top">
but as i'm new to JS especially DOM scripting, I don't know how.
Any help would be greatly appreciated.
Kind Regards,
Peter.
Instead of:
document.location.href="http://members.optushome.com.au/roeleven/Undercon/main.html";
Change it to:
window.parent.location.href="http://members.optushome.com.au/roeleven/Undercon/main.html";
should work. BTW, this is a straightfoward JavaScript question, so I'm transferring the thread over there.
reptilemart
09-24-2002, 02:05 PM
Thanks alot, it worked beautfully.
Much appreciated.
vkidv
09-24-2002, 05:52 PM
window.parent.location.href=" <url here>";
can you specify what frame to load-in?
window.parent
which is what frame ? what frame is the parent ?
is parent the whole page - it wont open in one specific frame ?
reptilemart
09-24-2002, 11:48 PM
Hi vkidv,
to me it looks as though window.parent is the top frame (not the frame at the top of the screen, but the whole page). It was only needed by me to load another frameset into the whole window.
I purchased a URL which is only pointing and cloaking at the moment. So instead of the URL leading to... for example : http://www.reptilemart.com/index it points the www.reptilemart.com URL to http://members.optushome.com.au/roeleven/Undercon. After it points the user to that location, it was cloaking the the URL by inserting my web-page into another frame (the page i needed to get out of) that displayed the www.reptilemart.com URL in the address bar. So now using the window.parent function, once the webpage loads it displays the longer & uglier URL, which also gives me access to cookies (the main reason i needed to do this).
Being new to JS i'm not sure how you would target specific frames in a frameset, but I did see something on this forum recently about it. Heres the address:
http://www.codingforums.com/showthread.php?s=&threadid=6667
Good luck.
glenngv
09-25-2002, 03:56 AM
using window.parent is not safe if you have a frame within a frame and you are in the innermost frame and you want to get out of the outermost frame.
use top instead:
top.location.href="http://members.optushome.com.au/roeleven/Undercon/main.html";
to target to a specific frame:
top.frames['FrameNameHere'].location.href="http://members.optushome.com.au/roeleven/Undercon/main.html";
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.