Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Using data with a single quote in a Javascript o pen


  • From: javascript@xxxxxxxxxx (Filipiak, Bob (Contractor))
  • Subject: [Javascript] Using data with a single quote in a Javascript o pen
  • Date: Fri, 28 Sep 2001 10:25:31 -0400

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C14829.6D91DF60
Content-Type: text/plain;
	charset="iso-8859-1"

There is some great help on ASP at
http://www.asplists.com/asplists/aspclient.asp

On your ASP page try concatenating the line before response.write:

Dim lineOut
lineOut = "<a href="
lineOut= lineOut & chr(34) &"#" chr(34)
lineOut= lineOut & " onClick=" & chr(34) & "javascript:window.open"
lineOut= lineOut & "('radiopopupgenerator.htm?MP3="
lineOut= lineOut & Server.HTMLEncode(rs.Fields("FileName").Value)
lineOut= lineOut & "&title="
lineOut= lineOut & Server.HTMLEncode(rs.Fields("StoryName").Value)
lineOut= lineOut &
"','Audio','width=240,height=190,location=no,menubar=no,scrollbars=no,status
=no,toolbar=no,resizable=yes');"
lineOut= lineOut & chr(34) & ">"

response.write lineOut

Bob Filipiak
(Contractor)


-----Original Message-----
From: David Chance [mailto:david_chance@xxxxxxxxxxxx]
Sent: Friday, September 28, 2001 12:00 AM
To: javascript@xxxxxxxxxx
Subject: [Javascript] Using data with a single quote in a Javascript
open


How can I use data with a single quote in a Javascript open
window statement??

I'm retreiving data from Access using asp, and I'm then using an
on click window.open to open a window that loads up RealPlayer
content:

<a href="#"
onClick="javascript:window.open('radiopopupgenerator.htm?MP3=<%=Server.HTMLE
ncode(rs.Fields("FileName").Value)%>&title=<%=Server.HTMLEncode(rs.Fields("S
toryName").Value)%>','Audio','width=240,height=190,location=no,menubar=no,sc
rollbars=no,status=no,toolbar=no,resizable=yes');">

The problem happens when some of my data has single quotes in
it. The page chokes.

I'm assuming I need to be place the recordset value in a
variable and parse for the ' and add a second one to it, but I'm
having problems doing this.

Any ideas??

Thanks a lot!!!

------_=_NextPart_001_01C14829.6D91DF60
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2652.35">
<TITLE>RE: [Javascript] Using data with a single quote in a Javascript =
open</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>There is some great help on ASP at <A =
HREF=3D"http://www.asplists.com/asplists/aspclient.asp"; =
TARGET=3D"_blank">http://www.asplists.com/asplists/aspclient.asp</A></FO=
NT>
</P>

<P><FONT SIZE=3D2>On your ASP page try concatenating the line before =
response.write:</FONT>
</P>

<P><FONT SIZE=3D2>Dim lineOut</FONT>
<BR><FONT SIZE=3D2>lineOut =3D &quot;&lt;a href=3D&quot;</FONT>
<BR><FONT SIZE=3D2>lineOut=3D lineOut &amp; chr(34) &amp;&quot;#&quot; =
chr(34)</FONT>
<BR><FONT SIZE=3D2>lineOut=3D lineOut &amp; &quot; onClick=3D&quot; =
&amp; chr(34) &amp; &quot;javascript:window.open&quot;</FONT>
<BR><FONT SIZE=3D2>lineOut=3D lineOut &amp; =
&quot;('radiopopupgenerator.htm?MP3=3D&quot;</FONT>
<BR><FONT SIZE=3D2>lineOut=3D lineOut &amp; =
Server.HTMLEncode(rs.Fields(&quot;FileName&quot;).Value)</FONT>
<BR><FONT SIZE=3D2>lineOut=3D lineOut &amp; =
&quot;&amp;title=3D&quot;</FONT>
<BR><FONT SIZE=3D2>lineOut=3D lineOut &amp; =
Server.HTMLEncode(rs.Fields(&quot;StoryName&quot;).Value)</FONT>
<BR><FONT SIZE=3D2>lineOut=3D lineOut &amp; =
&quot;','Audio','width=3D240,height=3D190,location=3Dno,menubar=3Dno,scr=
ollbars=3Dno,status=3Dno,toolbar=3Dno,resizable=3Dyes');&quot;</FONT></P=
>

<P><FONT SIZE=3D2>lineOut=3D lineOut &amp; chr(34) &amp; =
&quot;&gt;&quot;</FONT>
</P>

<P><FONT SIZE=3D2>response.write lineOut</FONT>
</P>

<P><FONT SIZE=3D2>Bob Filipiak</FONT>
<BR><FONT SIZE=3D2>(Contractor)</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: David Chance [<A =
HREF=3D"mailto:david_chance@xxxxxxxxxxxx";>mailto:david_chance@xxxxxxxxxx=
au</A>]</FONT>
<BR><FONT SIZE=3D2>Sent: Friday, September 28, 2001 12:00 AM</FONT>
<BR><FONT SIZE=3D2>To: javascript@xxxxxxxxxx</FONT>
<BR><FONT SIZE=3D2>Subject: [Javascript] Using data with a single quote =
in a Javascript</FONT>
<BR><FONT SIZE=3D2>open</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>How can I use data with a single quote in a =
Javascript open</FONT>
<BR><FONT SIZE=3D2>window statement??</FONT>
</P>

<P><FONT SIZE=3D2>I'm retreiving data from Access using asp, and I'm =
then using an</FONT>
<BR><FONT SIZE=3D2>on click window.open to open a window that loads up =
RealPlayer</FONT>
<BR><FONT SIZE=3D2>content:</FONT>
</P>

<P><FONT SIZE=3D2>&lt;a href=3D&quot;#&quot;</FONT>
<BR><FONT =
SIZE=3D2>onClick=3D&quot;javascript:window.open('radiopopupgenerator.htm=
?MP3=3D&lt;%=3DServer.HTMLEncode(rs.Fields(&quot;FileName&quot;).Value)%=
&gt;&amp;title=3D&lt;%=3DServer.HTMLEncode(rs.Fields(&quot;StoryName&quo=
t;).Value)%&gt;','Audio','width=3D240,height=3D190,location=3Dno,menubar=
=3Dno,scrollbars=3Dno,status=3Dno,toolbar=3Dno,resizable=3Dyes');&quot;&=
gt;</FONT></P>

<P><FONT SIZE=3D2>The problem happens when some of my data has single =
quotes in</FONT>
<BR><FONT SIZE=3D2>it. The page chokes.</FONT>
</P>

<P><FONT SIZE=3D2>I'm assuming I need to be place the recordset value =
in a</FONT>
<BR><FONT SIZE=3D2>variable and parse for the ' and add a second one to =
it, but I'm</FONT>
<BR><FONT SIZE=3D2>having problems doing this.</FONT>
</P>

<P><FONT SIZE=3D2>Any ideas??</FONT>
</P>

<P><FONT SIZE=3D2>Thanks a lot!!!</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C14829.6D91DF60--