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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass a url encoded string 1

Status
Not open for further replies.

malonep

Programmer
Jul 14, 2004
44
CA
Hi,
I want to pass a url encoded string to a new window that is opened with javascript but, when the page opens the string is displayed in the address bar as the original symbols.

Main Page
Code:
strCaption = "!@#$%^&*()"
strCaption = convertURL(strCaption)
'strCaption is now = "!%40%23%24%25%5E%26*()"

%><script>
window.open("details.asp?caption=<%=strCaption%>")

On the Details Page the url is displayed as
(NOT url encoded)
and when I try to display the caption string
Code:
Response.write(Request.QueryString("caption"))
I only get a partial string of !@

if I manually change the url to contain url encoding the entire string is displayed

Why in both IE and Netscape if I open a new window using javascript and try to pass it a url encoded string the new window doesn't keep the url encoding?

How do I pass a url encoded string to a new window through javascript

Thanks,
malonep
 
Use the escape function, and once you get it to your new page, use unescape to get it back to normal.
Code:
strCaption = "!@#$%^&*()"
strCaption = escape(strCaption);
alert(strCaption);
strCaption = unescape(strCaption);
alert(strCaption);

-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top