Results 1 to 2 of 2
Apr 8, 2009, 01:11 #1
no way to escape single quote or double quote inside of onclick=' something ' ?
For the following code, it seems like we cannot escape the single quote? (for Bill Gates's dog). No matter how it is done, the single quote will be taken as the closing single quote for the onclick=' ?
<a href="#" onclick='changeIt("Bill Gates\'s dog said &quot;Whoof Whoof!&quot; and \n \r\n \t ran away."); return false;'>Click me</a>
is there really a way around it except to use &#039; to replace that single quote? thanks.
Apr 8, 2009, 10:07 #2
- Join Date
- Nov 2004
- 0 Post(s)
- 0 Thread(s)
It's an HTML attribute, so you'll need to escape characters HTML-style. That means a character entity or a numeric character reference. For the apostrophe, HTML doesn't have a named entity (XHTML does – ' – but that's only allowed in real XHTML which virtually no-one uses). So in this case you need the NCR: &#39;.
<a href="#" onclick='changeIt("Bill Gates's dog said &quot;Whoof Whoof!&quot; and \n \r\n \t ran away."); return false;'>Click me</a>Birnam wood is come to Dunsinane