简体   繁体   English

如何在Web Worker中访问Chrome API?

[英]How to access Chrome API in Web Worker?

I have some metadataWorker.js in my Chrome App, It is Web Worker and runs as follows: 我的Chrome应用程序中有一些metadataWorker.js ,它是Web Worker,运行方式如下:

metaThread = new Worker('/src/utils/metadataworker.js');

But I can't access the chrome global object in metadataworker.js . 但是我无法访问metadataworker.jschrome全局对象。

Is there any way to use Chrome API (access the chrome global object) in Web Worker? 有什么方法可以在Web Worker中使用Chrome API(访问chrome全局对象)?

You can't access chrome object from web worker. 您无法通过Web Worker访问Chrome对象。 This is sandboxed from the app and it run in separate thread. 这是从应用程序中沙盒化的,并且在单独的线程中运行。 You can only use web APIs inside a web worker, without DOM access. 您只能在Web Worker中使用Web API,而不能访问DOM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM