简体   繁体   English

Javascript语法和HTML实体

[英]Javascript syntax and HTML entities

I work on some crawler software of my own and one of my users just reported it will not work with code like this: 我正在使用自己的某些爬虫软件,并且我的一个用户刚刚报告说它不适用于以下代码:

onclick="document.location.href = 'http://www.example.com/somepage.aspx'; return false;"

ie inside Javascript code use ' Javascript代码中使用' instead of ' to designate start end end of string 代替'来指定字符串的开始结束

What surprises me is that browsers I have tested do not report any JavaScript syntax errors... And it seems to work when I click at it... I must be having a brain meltdown - is ' 让我感到惊讶的是,我测试过的浏览器没有报告任何JavaScript语法错误...当我单击它时它似乎可以正常工作...我一定会崩溃-是' around a string really legitimate Javascript code? 字符串是否真的合法的Java代码?

is ' ' around a string really legitimate Javascript code? 字符串是否真的合法的Java代码?

No. The browser will decode the character references before evaluating the value as JavaScript. 不会。浏览器将在将值评估为JavaScript之前对字符引用进行解码。

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

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