PDA

View Full Version : get URL of parent after 5 seconds


brenthel
10-21-2002, 08:45 PM
Basically i trying to retrieve the URL of my parent window after a certain amout of time. Calling cookie_Decider() in the onUnload of the parent page. This code is in the child window. Can this be done? or is there anthor solution to get the same result


function cookie_Decider()
{
setTimeout("check_URL()",5000);
/*one problem is that setTimeout fires right away just displays the results at a later point in time */
}//end function



function check_URL()
{
var run_move=false;
var parent_url = null;
parent_url=new String(window.parent.location);
var parent_url2 = parent_url.substr(7,10);
var server_name = "<?php print $SERVER_NAME; ?>";
var server_name2 = server_name.substr(0,10);

if(server_name2.match(parent_url2)==null)
{
alert("true");
// run_move=true;
}
else
{
window.location.reload();

// run_move=false;
}


if(run_move == true)
{
alert("run=True");
// window.moveTo(300,100);
// window.focus();
}

}//end function

smeagol
10-23-2002, 10:32 PM
You can get the URL of the Parent Window by using the following in the child window:

window.opener.location;

This will return the URL of the window that opened the child window.

Is this what you're looking for?

beetle
10-24-2002, 02:25 AM
opener refers to a document's opener windows (if the document is a popup, that is)

parent refers to a window's parent window, as in a frameset.

setTimeout("parent_url = parent.location.href", 5000);