您在預定()函數的字符串由單引號分隔。這意味着您在該字符串中輸入的每個單引號都必須由a轉義。但是,這不是你的問題。你的問題在於無效的HTML。這是你擁有的一切:
$('#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;">');
如果你發現所有的HTML的屬性值是由雙引號分隔。但是,在您的onclick =「」事件中,您再次使用雙引號。您可以使用ESCAPED單引號來糾正此衝突。你的oncontextmenu =「」事件也有同樣的問題。
$('#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函數調用外部串(HTML),然後通過在字符串中作爲一個變量。
它是一個HTML屬性值; \毫無意義。 – Quentin
啊,謝謝!!!!! – user1098767
@Quentin正確,更新。 –