> -----Original Message-----
> From: Robert Harrison [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 02, 2007 1:58 PM
> To: CF-Talk
> Subject: OT: Java Script Question
>
>
> Sorry for the OT JS question, but I need this to work and someone my
> see the
> problem.
>
> I'm creating a function to write a tag with some external variables.
> I'm
> using document.write, but the < and > symbols in the tag are giving me
> a
> fit. I tried using < and >, but the browser just displays the tag
> then. It doesn't execute it.
>
> I should be able to do:
>
> function writetag () {
> document.write ("<a href="""+myurlvar+"""><img
> src="""+myimgvar+""></a>");
> }
In JavaScript you escape special characters with the backslash:
document.write ("<a href=\"" + myurlvar + "\"><img src=\"" + myimgvar +
"\"></a>");
Note that you can also often simplify this by just using single quotes:
document.write ("<a href='" + myurlvar + "'><img src='" + myimgvar +
"'></a>");
> The do <script language-"javascript">writetag</script>
Here you would need parenthesis to indicate that you're calling a function:
<script language-"javascript">writetag();</script>
> but it don't work. Anyone have any ideas?
That should do it I think - give 'er a shot.
Jim Davis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:285239
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4