我如何从Google CDN加载jquery? [英] How can I load jquery from Google CDN?

查看:96
本文介绍了我如何从Google CDN加载jquery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想在本地托管多一个jquery lib来创建另一个插件。我试图从谷歌的CDN加载它,但我得到这个异常:

I don't want to create one more plugin with one more jquery lib hosted locally. I'm trying to load it from Google's CDN but I'm getting this exception:


拒绝加载脚本'http:// ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js',因为它违反了以下内容安全策略指令:script-src'self'chrome-extension-resource:。

Refused to load the script 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js' because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:".

我该如何解决它?

How can I fix it?

推荐答案

如果您想从Google CDN加载jQuery,您必须将以下内容安全规则添加到您的清单文件中。 $ b

If you want to load jQuery from Google's CDN you have to add the following content security rule to your manifest file.


    ...
    "content_security_policy": "script-src 'self' https://*.googleapis.com; object-src 'self'",
    ...

欲了解更多信息,请阅读官方文件Sirwan Afifi已经提供,特别是遵循链接到 CSP规范关于HTML5的文章

For more information read the official documentation Sirwan Afifi already provided and especially follow the links there to the CSP specification and the article on HTML5 rocks.

这篇关于我如何从Google CDN加载jquery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆