By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,086 Members | 1,450 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,086 IT Pros & Developers. It's quick & easy.

Problem with "onClick" command

P: n/a
I have a prblem with the "onClick" command.
onClick="insert('<a href="URI">', '</a>')">

but this is not correct! why?
Maria
Jul 3 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Maria Sudderman wrote on 03 jul 2007 in comp.lang.javascript:
I have a prblem with the "onClick" command.
onClick="insert('<a href="URI">', '</a>')">

but this is not correct! why?
What kind of function is insert(), javascript????
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 3 '07 #2

P: n/a
d d
Maria Sudderman wrote:
I have a prblem with the "onClick" command.
onClick="insert('<a href="URI">', '</a>')">
but this is not correct! why?
Maria
Nested quotes. Try this:

onClick="insert('<a href=\"URI\">', '</a>')">

~dd
Jul 3 '07 #3

P: n/a
On Jul 3, 5:12 pm, d d <dd_no_s...@please.netwrote:
Nested quotes. Try this:

onClick="insert('<a href=\"URI\">', '</a>')">
The improper nesting is causing problems at the HTML parsing level,
not the JS level.

onclick="insert('<a href=&quot;URI&quot;>', '</a>')">

.... although I would avoid any JavaScript that accepted raw markup as
input.

--
David Dorward

Jul 3 '07 #4

P: n/a
thanks, this is the answer

"David Dorward" <do*****@gmail.comschrieb im Newsbeitrag
news:11**********************@q69g2000hsb.googlegr oups.com...
On Jul 3, 5:12 pm, d d <dd_no_s...@please.netwrote:
Nested quotes. Try this:

onClick="insert('<a href=\"URI\">', '</a>')">
The improper nesting is causing problems at the HTML parsing level,
not the JS level.

onclick="insert('<a href=&quot;URI&quot;>', '</a>')">

.... although I would avoid any JavaScript that accepted raw markup as
input.

--
David Dorward
Jul 3 '07 #5

P: n/a
d d wrote:
Maria Sudderman wrote:
>I have a prblem with the "onClick" command.
onClick="insert('<a href="URI">', '</a>')">
but this is not correct! why?
Maria

Nested quotes. Try this:

onClick="insert('<a href=\"URI\">', '</a>')">
In the context of a javascript string literals appearing in an HTML
attribute value it would be safer to transform the inner quotes into
Unicode or hex escape sequences as that renders them unrecognisable to
the HTML parser:-

onclick="insert('<a href=\x22URI\x22>', '</a>')">
-or:-
onclick="insert('<a href=\u0022URI\u0022>', '</a>')">

Richard.

Jul 3 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.