aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Error while manipulating parent window URL in child window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Error while manipulating parent window URL in child window" Watch "Error while manipulating parent window URL in child window" New topic
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

Line: 15
Char: 1
Error: Object doesn't support this property or method
Code:0
URL: http://localhost:9085/EPOApp/epo_child.jsp


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: 15376
    
    6
I would expect window.opener.location.href or window.opener.location.search

Eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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: 15376
    
    6
You are doing web development and you do not know about Firebug?

Eric
 
wood burning stoves
 
subject: Error while manipulating parent window URL in child window