所以我的控制台给了我这条消息-
The page at https://en.wikibooks.org/wiki/Vehicle_Identification_Numbers_(VIN_codes)/GM/VIN_Codes ran insecure content from http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js.
jquerified: true
ERROR: Execution of script 'GMVinCodeScraper' failed! $ is not defined
ReferenceError: $ is not defined
at getGMCodes (eval at <anonymous> (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21))))
at Function.eval (eval at <anonymous> (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21))))
at N (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21)))
at l (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21)))
at chromeEmu.extension.onRequest.addListener.Z (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21)))
at W (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21)))在我的用户脚本中,我正在运行一个自动在页面上包含jquery的函数,似乎已经加载了jquery,因为我可以看到一个脚本标记,其中jquery url作为src属性。
该函数在这里供参考-
function jquerify(jquerified){
if(!(window.JQuery && window.Jquery.fn.jquery == '1')){
var s = document.createElement('script');
s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
s.setAttribute('type','text/javascript');
document.getElementsByTagName('head')[0].appendChild(s);
jquerified = true;
console.log("jquerified: " + jquerified);
return jquerified;
}
}
jquerify(false);所以,我不确定为什么不定义$。知道为什么吗?
更新-
使用@require解决了这个问题。
发布于 2012-08-08 03:02:31
您可以通过使用@require url来解决此问题
发布于 2019-04-26 12:51:55
将此代码添加到您的脚本头。
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js然后,您可以使用$()。
https://stackoverflow.com/questions/11852109
复制相似问题