Forum Moderators: open

Message Too Old, No Replies

Child window location.href

         

JasonD

11:27 pm on Jun 30, 2004 (gmt 0)

10+ Year Member



Hi everyone,

As I am more into Perl than JS I am getting stuck in a little problem I hope you can help with.

Is it possible (and if so how) for a parent window to get a child window's location.href?

In essence I want to open a window, wait for a set amount of time - then query the child window to see if the location.href has changed.

I'm pretty sure it's a simple matter but at 12.30am I'm stumped! (Maybe I should just go to bed)

Thanks

Jason

Rambo Tribble

5:11 am on Jul 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If the URL for the file in the second window is from the same domain, and you open the window as something like:
var winX=window.open("test_WnURL_b.htm","","width=100,height=50");

Then the code:
var x=winX.location.href;
alert(x);

Will reveal the URL of the window. If, however, the contents of the second window are from another domain than the first, the URL is not available due to the security constraints of the "Same Origin Policy".

JasonD

8:27 am on Jul 1, 2004 (gmt 0)

10+ Year Member



Thankyou very much.

I was on the right track with the code (I got it right in fact) except I wasn't aware of the security restrictions. Thanks for explaining why I had the problems I have..... (Well the JavaScript ones anyway :P )