javascript - Onclick confirm() not working when echoed by PHP -


i'm trying use javacript confirm() box via php echo below , it's not working.

echo '<a href="http://sdfsdfs.com?keepthis=true&tb_iframe=true&height=10&width=1200&x=2342342&enter_other_room=2" class="box" target="_self" oncontextmenu="return false;" onclick="confirm(\"are sure want enter users\'s room?\");\">user\'s room</a>'; 

what missing here?

you can't escape quotes inside html attributes, onclick="confirm(\"...\");" won't work. put single quotes around string. , since it's inside php single-quoted string, need escape them php.

and since string contains apostrophe inside it, need escape javascript. have double backslashes literal backslash php string. , third backslash escape php.

echo '<a href="http://sdfsdfs.com?keepthis=true&tb_iframe=true&height=10&width=1200&x=2342342&enter_other_room=2" class="box" target="_self" oncontextmenu="return false;" onclick="confirm(\'are sure want enter users\\\'s room?\');\">user\'s room</a>'; 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -