我使用urlive库来使用链接加载缩略图图像。
除了Chrome扩展之外,它的功能也是完美的。但是,当在Chrome扩展中运行相同的功能时,我得到了错误:
“拒绝加载脚本
'http://query.yahooapis.com/v1/public/yql?callback=jQuery1111091462301090359…22+and+xpath%3D%22*%22+and+compat%3D%22html5%22&format=xml&_=1417426473922',因为它违反了以下内容安全策略指令:"script-src 'self' 'unsafe-eval'".
$(document).ready(function() {
$('#thumbnail_url').on('input propertychange', function () {
console.log('called');
$('#thumbnail_url').urlive({
callbacks: {
onStart: function () {
console.log('called1');
$('.loading').show();
$('.urlive-container').urlive('remove');
},
onSuccess: function (data) {
$('.loading').hide();
$('.urlive-container').urlive('remove');
},
noData: function () {
$('.loading').hide();
$('.urlive-container').urlive('remove');
}
}
});
}).trigger('input');
});我已经试过了所有的可能性。但我没有得到答案。在调用yahooapis时,仍然会引发错误。
发布于 2015-02-12 19:48:29
如果您正在处理chromeapp,那么就别管urlive库了。“urlive`”将使用yahooapis,而yahooapis在构建chrome应用程序时不起作用。它不断增加错误。所以最好与其他库一起使用。
发布于 2014-12-01 09:52:17
将雅虎域添加到规则中:"script-src 'self' 'unsafe-eval' http://query.yahooapis.com"
有关更多信息:http://content-security-policy.com/
https://stackoverflow.com/questions/27225463
复制相似问题