Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
简单jquery脚本在chrome中不起作用。不允许的字符?_Jquery - Fatal编程技术网

简单jquery脚本在chrome中不起作用。不允许的字符?

简单jquery脚本在chrome中不起作用。不允许的字符?,jquery,Jquery,我有一个小脚本,用于检测当前用户所在的URL,并在满足URL条件时显示一些内容 <script type='text/javascript'> $(function () { if (location.pathname == "/ProductDetails.asp" || location.pathname.indexOf("-p/") != -1) { var content = "<div class='ad-bar'><ul>&

我有一个小脚本,用于检测当前用户所在的URL,并在满足URL条件时显示一些内容

<script type='text/javascript'>
$(function () {
    if (location.pathname == "/ProductDetails.asp" || location.pathname.indexOf("-p/") != -1) {
        var content = "<div class='ad-bar'><ul><li class='ad-bar-ship'><a href='/shipping-info_a/57.htm' target='_blank'><span>FREE SHIPPING!</span><br />on your order over $39</a></li><li class='ad-bar-price'><a href='/price-match-guarantee_a/289.htm' target='_blank'><span>SEEN A LOWER PRICE?</span><br />let us know here, and we'll beat it!</a></li><li class='ad-bar-coupon'><a href='/find-me-a-coupon_a/290.htm' target='_blank'><span>COUPON HUNTING?</span><br />let us find one for you!</a></li></ul></div>";

        var el = $('#v65-product-parent');

        // If there's an element with id = content_area in the page,
        // let's insert the content after it.
        // Otherwise, let's insert it to the body.
        if (el != null) {
            $(el).after(content);
        }
        else {
            $('body').append(content);
        }
    }
});
</script>

$(函数(){
if(location.pathname==“/ProductDetails.asp”| | location.pathname.indexOf(“-p/”)!=-1){
var content=“
  • ”; var el=$(“#v65产品母公司”); //如果页面中有id=content\u区域的元素, //让我们在它后面插入内容。 //否则,让我们将其插入到主体中。 如果(el!=null){ $(el).在(内容)之后; } 否则{ $('body')。追加(内容); } } });
该脚本在IE和Firefox中运行良好,但在chrome中不起作用。我尝试将我希望显示的内容替换为一个简单的单词,效果很好。我希望显示的内容中有一些元素或字符与Chrome不兼容

我有点像jquerynoob。内容中是否有我不允许使用的字符?单一报价不起作用吗


谢谢-Alex

我在Firefox和Chrome中都无法使用该代码,但这不是因为您使用了错误的代码AdBlock由于它的类
ad bar
,所以只会阻止您的div。所以,试着关闭你的Adblock,看看它是否有效——如果有效,你应该重新命名你的类,以免再被Adblock捕获。

你使用的是GreaseMonkey还是UserScript?我不确定。我真的不知道有什么区别,就是这样。在将来选择类名时,我一定要记住这一点。谢谢