Hey, who keeps chaning my escaped character!

R

Rob Morrison

The sample below demonstates an issue that I cannot seem to workaround. I
have an Url with a value that contains an ampersand. I have escaped the Url
using both the hex value and it works fine when used in a href. But, if I
pass the same Url to the open() function it unescapes my ampersand while
leaving the other escaped untouched. This behavior is the same for both IE
and Mozilla Firefox, I guess this is known behvoir unknown to me.

Does anybody know how to pass an ampersand in a name value pair to the open
function?

Sample:

<%@ Language=javascript %>
<html>
<script language="javascript">
function showEscapeVar() {
alert('<%=Request.QueryString("escapevar").Item%>');
return false;
}
</script>
<body onload="showEscapeVar()">


<a href="whoatemyescape.asp?escapevar=Sanford%20%26%20Son">Href
Escape</a>

<a
href="javascript:eek:pen('whoatemyescape.asp?escapevar=Sanford%20%26%20Son')">P
opup Escape</a>


</body>
</html>
 
T

Thomas 'PointedEars' Lahn

Rob said:
Does anybody know how to pass an ampersand in a name value pair to the
open function?

`&amp;', if window.open() is called in an event handler.
Sample:

<%@ Language=javascript %>

This should be


<!DOCTYPE html PUBLIC "-//W3C//DTD HTMl 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script language="javascript">

<script type="text/javascript">

See said:
function showEscapeVar() {
alert('<%=Request.QueryString("escapevar").Item%>');

AFAIK you can omit ".Item".
return false;
}
</script>

<body onload="showEscapeVar()">


<a href="whoatemyescape.asp?escapevar=Sanford%20%26%20Son">Href
Escape</a>

<a
href="javascript:eek:pen('whoatemyescape.asp?escapevar=Sanford%20%26%20Son')">P
^^^^^^^^^^
opup Escape</a>

Don't depend on client-side scripting when you are not required
to. You have ASP available, make use of it whereever possible.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top