当我尝试粘贴到HTML文本文件中时,我总是被踢出外壳。如何才能做到这一点?我首先需要使用一些JavaScript对其进行编码吗?
例:
db.test.insert({x:"<div id='product-description'><p>Who hasn’t wished for a mini-Roomba to handle the arduous task of cleaning their iPhone screen? Now your dreams have come true!</p> <p>See the Takara web page for a <a href='http://www.takaratomy.co.jp/products/automee/' title='automee s' target='_blank'>demo video.</a></p> <p><strong>Colors: </strong> White, Red, Orange and Blue<br> Runs on a single AA battery.</p> <p>1,575 yen</p><!-- end #product-description --></div>"})
编辑
我只在HTML中放入单引号,然后将整个内容都用双引号引起来,但仍然没有好处。外壳错误:
> j = ({z:"<div id='product-description'><p>Who hasn --- Unicode text could not be correctly displayed. Please change your console font to a Unicode font (e.g. Lucida Console). --- ’ bye
您需要删除或编码字符串中的控制字符。
例如,将您的文本粘贴到此处,然后编码为UTF-8 ECMAScript(表示javascript字符串)。
ps:这里是有关javascript中字符串的文章。告诉您什么需要转义。http://docstore.mik.ua/orelly/webprog/jscript/ch03_02.htm