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

URLEcoded Format / Javascript 1

Status
Not open for further replies.

DeZiner

Programmer
May 17, 2001
815
0
0
US
I am pulling a name from a database with a url to go with it. The name appears as a link. In the link I am using the javascript mouseover to change the window status. If the name happen's to have an apostrophe (one of these ') I get a javascript error. If I use URLEncodedFormat it ignores the ' but then the status has %20 all over it for every space. Any ideas how to change the status without the ' interferring?

<a href=&quot;#URL#&quot; onMouseover=&quot;window.status=('#name#'); return true&quot;>#name#</a> --Not working

<a href=&quot;#URL#&quot; onMouseover=&quot;window.status=('#URLEncodedFormat('#name#')#'); return true&quot;>#name#</a>
-- Not quite good enough DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
you might want to try to prepare the string to be used with javascript by replacing all ' and prefix it with javascript escape signs:

try something like this:

<cfset tempName = Replace(name, &quot;'&quot;, &quot;\'&quot;))

<a href=&quot;#URL#&quot; onMouseover=&quot;window.status=('#tempName#'); return true&quot;>#name#</a> Sylvano
dsylvano@hotmail.com

&quot;every and each day when I learn something new is a small victory...&quot;
 
BTW, I'm thinking you are using the variable #URL# as just an exampple for TekTips forum, but if you are really using a variable named URL (which is a ColdFusion reserved word and scope), then I suggest changing it. If you are pulling it strait from the DB then simply us &quot;AS&quot; in the query.

SELECT name, URL as theURL FROM myTable - tleish
 
Thanks for all the help I will give this a try. Using #URL# just for exapmle, thanks for the heads-up though! DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top