最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Cannot read property 'noConflict' of undefined (Chrome Extension) - Stack Overflow

programmeradmin6浏览0评论

I have a chrome extension which is using jQuery as content script with noconflict like;

var myDomainJquery = $.noConflict(true);

on the other hand some websites are also using jQuery noconflict on their way like; for example new york times

<script>var jQ = jQuery.noConflict(true);</script> 

Then I am getting Cannot read property 'noConflict' of undefined error on the host website.

Is there any way to fix this problem?

I have a chrome extension which is using jQuery as content script with noconflict like;

var myDomainJquery = $.noConflict(true);

on the other hand some websites are also using jQuery noconflict on their way like; for example new york times

<script>var jQ = jQuery.noConflict(true);</script> 

Then I am getting Cannot read property 'noConflict' of undefined error on the host website.

Is there any way to fix this problem?

Share Improve this question asked Jun 5, 2014 at 16:28 Teoman shipahiTeoman shipahi 23.2k16 gold badges144 silver badges173 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 4

Yes, there is. The way to fix it is to understand the isolated context content scripts run in.

A content script has no access to any JS loaded by the page itself; if you need jQuery, you need to package it with your extension and inject it yourself first. On the bright side, there can be no conflict with the page, and you can simply use $.

发布评论

评论列表(0)

  1. 暂无评论