简体   繁体   中英

Escape double quotes in JavaScript

I'm a student who has to deal with an intern hacking challenge. I'm that far that I'm able to insert JavaScript code.

My one and only problem... I can't use single quotes since the firewall blocks it.

Double quotes are giving me an error because of double use:

<a id="bb" href="javaSCRIPT&colon;document.body.innerHTML = "lol"">clicks</a>

How can I use the above line of code, just like using single quotes?

<a id="bb" href="javaSCRIPT&colon;document.body.innerHTML = 'lol'">clicks</a>

(Try it in an empty HTML document, please.)

This should work for you;

<a id="bb" href="javascript&colon;document.body.innerHTML=&quot;foo&quot;">clicks</a>

Here's an example: http://jsfiddle.net/49ay5jwf/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM