跨域Web工作人员 [英] Cross Domain Web Workers
问题描述
我知道这个问题可能被认为是重复的,但这是一项新技术,我无法找到最近对我的发现的证实.我还认为将所有错误消息放在一个位置(可以随意添加任何其他浏览器)可能很有用.
试图从另一个域加载工作脚本:
新工作者('http://otherdomain.co/worker.js');
我已将标题(使用 ModHeader Chrome扩展程序)设置为:>
<代码>访问控制允许方法:*访问控制允许来源:*
但是在Chrome浏览器中,我得到了:
未捕获的安全错误:无法构造'Worker':无法从原始位置访问'http:otherdomain.co/worker.js'上的脚本
Safari给我:
[错误] SecurityError:DOM异常18:试图突破用户代理的安全策略
Firefox给了我
SecurityError:操作不安全.
这不是我们不能做的吗?如果是这样,那么什么被认为是最佳实践呢?
通过此方法,您可以轻松地使用本地脚本而不是远程URL创建Worker.
I am aware that this question might be considered duplicate, but it is a new technology and I can not find a recent confirmation of my findings. I also think it potentially useful to have all the error messages in one place (feel free to add any other browsers).
trying to loads a worker script from another domain:
new Worker('http://otherdomain.co/worker.js');
I have set headers (using ModHeader Chrome Extension) to:
Access-Control-Allow-Methods:*
Access-Control-Allow-Origin:*
But in Chrome I get:
Uncaught SecurityError: Failed to construct 'Worker': Script at 'http:otherdomain.co/worker.js' cannot be accessed from origin
Safari give me:
[Error] SecurityError: DOM Exception 18: An attempt was made to break through the security policy of the user agent
Firefox gives me:
SecurityError: The operation is insecure.
Is it still that this is not something we can do? If so, what is considered the best practise work around?
I know it's a little late now, but is this what you're looking for?
"Creates a url for the specified blob that can be passed to methods that expect a url. When done with the returned url, call revokeObjectURL() to free the resources associated with the created url."
This method easily allows you to create a Worker using a local script instead of a remote url.
这篇关于跨域Web工作人员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!