There's more than one way to do things | |
PerlMonks |
Re: Perl, JavaScript and quoting/escapingby isync (Hermit) |
on Sep 23, 2008 at 18:11 UTC ( [id://713268]=note: print w/replies, xml ) | Need Help?? |
Actually I solved it half-way: The problem is less the quoting on the perl side, but what ends up in the html output:
\" becomes " - so inside the href="" we can use the single-quote ' to differentiate things. And if in these single-quotes values need to be presented we double quote \\' so the \' ends up in the html, like example.jsfunction('<a href=\'\'></a>') But still I am in trouble if I need to add yet another nested layer of quoted values, for example example.jsfunction('<a href=\'\' onclick=\\'alert('test')\\'></a>') - what shoudl I do with the quotes around test? Any ideas? Update: I've found out that, at least in Firefox, using entities works: example.jsfunction('<a href=\'\' onclick=\\'alert("test")\\'></a>') - but is that portable?
In Section
Seekers of Perl Wisdom
|
|