将webrequest api与事件页面一起使用时,会收到错误消息:
'webRequest'API不能与事件页面一起使用.
在网上看,我找到了这个主题:http://code.google.com/p/chromium/issues/detail?id = 119613
我的问题:为什么我们不能(或怎么能)同时使用两者?
如何加载谷歌字体,我真的必须下载并打包我的应用程序使用的每种字体吗?我试图避免打包字体,因为它们太多了我的应用程序会很大(它是一个网页编辑器)
<link href='http://fonts.googleapis.com/css?family=Nunito' rel='stylesheet' type='text/css'>
> Refused to load the stylesheet 'http://fonts.googleapis.com/css?family=Nunito' because it violates the following Content Security Policy directive: "style-src 'self' data: chrome-extension-resource: 'unsafe-inline'".
Run Code Online (Sandbox Code Playgroud)
我以为我可以加载它作为一个blob但我不确定它是否可以完成.数据已下载但没有变化,我试过这个:
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://themes.googleusercontent.com/static/fonts/nunito/v4/0rdItLTcOd8TSMl72RUU5w.woff", true);
xhr.responseType = "blob";
xhr.onreadystatechange = function() {
console.log("STATE", xhr.readyState);
if (xhr.readyState == 4) {
var myfontblob = window.webkitURL.createObjectURL(xhr.response);
$("<style>").text("@font-face {\
font-family: 'Nunito';\
font-style: normal;\
font-weight: 400;\
src: '"+myfontblob+"' format('woff');\
}").prependTo("head");
}
};
xhr.send();
Run Code Online (Sandbox Code Playgroud)