简体   繁体   English

在 JavaScript 中转义双引号

[英]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.我已经可以插入 JavaScript 代码了。

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.) (请在空的 HTML 文档中尝试。)

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/这是一个例子: http : //jsfiddle.net/49ay5jwf/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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