Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.open and server.urlencode

Status
Not open for further replies.

tinac99

Programmer
Jan 17, 2002
58
US
Hi,

I passed an encoded URL as one of the parameters in the window.open function in Javascript.

Calling window
---------------
e.g.
../ViewDetail.asp?Symbol=ABCDE&Targetpage=http%3A%2F%2Ffinance%2Eyahoo%2Ecom%2Flookup%3Ft%3DM%26m%3DUS%26s%3D

The equivalent of Targetpage is

Called window
--------------
When I try to get the value of the TargetPage in the called window in ASP:

strTarget = Request("TargetPage")

it only gets the url up until the first parameter:


This seems to work when I do use
<a href=../ViewDetail.asp?Symbol=ABCDE&Targetpage=http%3A%2F%2Ffinance%2Eyahoo%2Ecom%2Flookup%3Ft%3DM%26m%3DUS%26s%3D>ABCDE</a>, retrieving the whole TargetPage string.

I was wondering why it wouldn't work with window.open in Javascript. I need to set the features of the called window(menubar,scrollbars,toolbar, etc...). If you have any answer, please let me know.

Also, is there a way to set these features of the called window(menubar,scrollbars,toolbar) in Javascript inside the called window?

Please advise.


Thank you very much,

Tina
 
Tina, can you post your code? (not all, just the relevant bits!)

Thanks

Nick
 
Tina, thinking about it, I know why it does this!

The reason you are only seeing:

is because even though you are encoding the url to pass to the popup, when the popup window opens the browser decodes it so looking at your full url:

ViewDetail.asp?Symbol=ABCDE&Targetpage=
The parameters you are actually passing here are:
Symbol=ABCDE
Targetpage=m=US
s=

because of the "&m" asp treats this as a new parameter.

So what you wanna do is have javascript fetch the encoded url from the original window. Something like this:

Code:
document.write(top.opener.document.getElementById('EncodedUrl').value);

And put a hidden field on your orignal page (in the above example I put this:

Code:
<input type="hidden" value="ViewDetail.asp?Symbol=ABCDE&Targetpage=http%3A%2F%2Ffinance%2Eyahoo%2Ecom%2Flookup%3Ft%3DM%26m%3DUS%26s%3D" id="EncodedUrl">

And there you have it!

Cheers

Nick
 
Thanks for your reply!

I have a question, though...
the line:

document.write(top.opener.document.getElementById('EncodedUrl').value);

Will this be in the calling window(1st window) or in the called window(2nd window)?

 
Hi nickdel,

I was able to make it to work. Thanks a lot!

Tina

 
Sorry, yeh it goes in the pop up window. I only used document.write to demonstrate it was working!

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top