简体   繁体   English

浏览器JavaScript需要Webworker

[英]Browser javascript require webworker

I have one running webworker and I want it to be able to load external source. 我有一个正在运行的Webworker,我希望它能够加载外部源。 How can I do it because it is run in another thread independent from DOM. 我该怎么办,因为它在独立于DOM的另一个线程中运行。 Thanks. 谢谢。

The importScripts method allows you to load external scripts that you can use in the web worker. importScripts方法允许您加载可在Web Worker中使用的外部脚本。 Note: Scripts that need the window object won't work here, because the window object is only accessible on the UI Thread. 注意:需要window对象的脚本在这里无法使用,因为window对象只能在UI Thread上访问。 More info can be found here 更多信息可以在这里找到

设置外部源,使其支持CORS

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

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