...

View Full Version : Child and Parent windows



maryhill
08-01-2002, 04:48 PM
I have a HTML file in a window (Window1) containing a textbox and a button.
The button opens a sized window (Window2) which the user can use to browse to whichever page they want anywhere on the internet.
When they close Window2 I want the last url they visited (i.e. the current url of Window2) to populate the text box on my original page (Window1) .
Can this be done?

Could you give me any pointers?

I would really appreciate any help you could give me.

Mary Hill
Senior Analyst
Sheffield Hallam University
ENGLAND

mordred
08-01-2002, 05:43 PM
Nope.
That cannot be done due to the same-origin security policy. You are only allowed to read the URL of files that reside in your domain, everything else is considered an infringe on privacy.

ShriekForth
08-01-2002, 05:50 PM
mordred is correct there, but.... if you were tracking on an intranet you could get the location of the child window by polling it.

Try this, it was a proof of concept. Note that it will only show URLS that are on the same server. It updates every second, and has a counter in it, the thought was to time how long the user was at a particular page. It never got off the ground as we convinced them it was not a good idea to spy so blatantly :)



<form name=temp method="post" action="http://www.xmission.com/~tnelson/mirror.php" onSubmit="return validateForm(this)">
<a href="javascript:showSecondWindow()">New Window</a><br>
<input type="text" name="URL" size="50" value=""><br>
</form>

<script language="JavaScript">
function showSecondWindow(){
Swin=window.open("","SecondWindow","");
Swin.document.clear();
Swin.document.close();
setTimeout("checkPage()",1000)

}
myCount = 0;
function checkPage(){
myCount++;
document.temp.URL.value = myCount + "URL: " + Swin.location;
setTimeout("checkPage()",1000)
}
</script>

ShriekForth



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum