jquery - 在提供内容时转义报价问题 [英] jquery - escaping quotes issue when prepending content
本文介绍了jquery - 在提供内容时转义报价问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下代码段:
I'm trying to use the following snippet:
$('#thirdPartyCheckoutButtons').prepend('<a href="https://www.resellerratings.com" onclick="window.open("https://seals.resellerratings.com/landing.php?seller=myID","name","height=760,width=780,scrollbars=1"); return false;"><img style="border:none;" src="//seals.resellerratings.com/seal.php?seller=myID" oncontextmenu="alert("Copying Prohibited by Law - ResellerRatings seal is a Trademark of All Enthusiast, Inc."); return false;" /></a><img src="https://www.myurl.com/hdsd834k.png" style="float: left;margin-left: 180px;">');
它根本没有显示..我尝试过这么多报价差异,
It isn't displaying at all.. I've tried so many quote differences, I don't get it!
推荐答案
内在的双引号破坏你的onclick属性值。用单引号替换它们并将其转出。
the inner-inner double quotes are breaking your onclick attribute value. Replace them with single quotes and escape them.
...onclick="window.open(\'https://seals.resellerratings.com/landing.php?seller=myID\',\'name\',\'height=760,width=780,scrollbars=1\'); return false;"...
同样的事情发生在您的oncontextmenu事件上,执行相同的修复。
The same thing happens on your oncontextmenu event, perform the same fix.
...oncontextmenu="alert(\'Copying Prohibited by Law - ResellerRatings seal is a Trademark of All Enthusiast, Inc.\'); return false;" />...
全部代码:
$('#thirdPartyCheckoutButtons').prepend('<a href="https://www.resellerratings.com" onclick="window.open(\'https://seals.resellerratings.com/landing.php?seller=myID\',\'name\',\'height=760,width=780,scrollbars=1\'); return false;"><img style="border:none;" src="//seals.resellerratings.com/seal.php?seller=myID" oncontextmenu="alert(\'Copying Prohibited by Law - ResellerRatings seal is a Trademark of All Enthusiast, Inc.\'); return false;" /></a><img src="https://www.myurl.com/hdsd834k.png" style="float: left;margin-left: 180px;">');
这篇关于jquery - 在提供内容时转义报价问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文