Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Anchor OnClick Problem

3 views
Skip to first unread message

CharlesEF

unread,
Oct 22, 2009, 2:34:23 AM10/22/09
to
Hi All,

I have looked at this line for so long I need new eyes. This is why I
am here. The below 1 line of code creates anchors (<a>) inside a
<div> element. I had no problems until I added the onclick action of
window.open(parm1, parm2);, now I get an error telling me that line 1
has a syntax error. If I remove parm2 from the anchor then a new
window does open with the html file shown and no error message. But I
need parm2 because I want the html file to display in the "_text"
frame of the HTA. The line below is 1 long line.

results.innerHTML += '<a id="' + objFilesRS.Fields("ID").Value + '"
title="' + objFilesRS.Fields("Description").Value + '" href=".\\html\
\' + objFilesRS.Fields("Filename").Value + '.html" value=".\\html\\' +
objFilesRS.Fields("Filename").Value + '.html" onclick="window.open
(this.value, "_text");return(false);">' + objFilesRS.Fields
("Filename").Value + '</a><br>';

Can anyone see my problem?


Thanks for any help,

Charles

Tom Lavedas

unread,
Oct 22, 2009, 9:54:16 AM10/22/09
to

I see and embedded double quote problem in the part after the
onclick. That is,

onclick="window.open(this.value, "_text");return(false);"

has double quotes within a double quoted string. I think this would
fix that ...

onclick=\'window.open(this.value, "_text");return(false);\'

by replacing the outer double quotes with single quotes - which need
to be escaped for the original insertion string to compile correctly.
_____________________
Tom Lavedas

CharlesEF

unread,
Oct 22, 2009, 2:12:30 PM10/22/09
to

Hi Tom,

Yes, that fixed the problem. I tried many things but I never thought
about escaping the single quotes.


Thanks for the help,

Charles

0 new messages