我想知道如何在图像标签中加载外部图像,例如:
<div id="page4">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRX1-0FwHVmDbsTFz8454Sx3fZFeQ-kO-xZ-Q6aYzMw3dCh6ybHT8TApuBPnA"/>
</div>
我必须向 manifest.json
添加什么?
出现以下错误:
Refused to load the image 'https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRX1-0FwHVmDbsTFz8454Sx3fZFeQ-kO-xZ-Q6aYzMw3dCh6ybHT8TApuBPnA' because it violates the following Content Security Policy directive: "img-src 'self' data: chrome-extension-resource:".
最佳答案
应用中的内容安全政策不能放宽。
如果你想在你的应用程序中混合外部资源(在 <webview>
之外),你需要 fetch them yourself :
You can fetch remote resources via XMLHttpRequest and serve them via blob:, data:, or filesystem: URLs (see Referencing external resources).
关于javascript - 在 Chrome 应用程序的 <img> 标签中加载外部图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24199119/