| Author |
Error while manipulating parent window URL in child window
|
Amit K Jain
Ranch Hand
Joined: Nov 06, 2008
Posts: 55
|
|
Hi,
I have to split the parent URL taken in child window to get a sub string out of it. If I use 'window.opener.document.location' to get the parent url and call split method it gives me the error below
I am launching the jsp from the html parent window.
My jsp code for child window:
Can someone please help on this?
Thanks
Amit
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
I would expect window.opener.location.href or window.opener.location.search
Eric
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Have you debugged what the variable holds before you split it? console.log is your friend.
Eric
|
 |
Amit K Jain
Ranch Hand
Joined: Nov 06, 2008
Posts: 55
|
|
Hi Eric,
Thanks you for your reply.
Yes. It is resolved by using 'window.opener.location.href'. I could print the value in alert for 'window.opener.location' which looks as expected hence moved on to split it. I do not have the right utility to debug the JS code and unfortunately I haven't done much work on JS. Can you please point me to any utility for it, any plugins in FireFox and its user guide?
BTW after making 'window.opener.location.href' working I notice that I can get the URL for parent window using 'window.opener.location.href' only when the parent and child window are running on same server and same application context. It doesn't work if they are in cross domain.
e.g.
this is the parent URL: http://localhost:9083/support/openair_test.html?uid=3PsN9DoC4hGRxiqe0PJLMg;app=rm;r=6Mcykfw3198;action=edit;save_action=paint;booking_id=50401
The Child page : http://localhost:9085/EPOApp/child.jsp
Could you please advise if this is feasible in javascript or is there any way to achieve this?
Thanks
Amit
|
 |
Amit K Jain
Ranch Hand
Joined: Nov 06, 2008
Posts: 55
|
|
Okay. So I tried document.referrer to get parent URL which resolved the issue.
Thanks
Amit
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
You are doing web development and you do not know about Firebug?
Eric
|
 |
 |
|
|
subject: Error while manipulating parent window URL in child window
|
|
|