本文介绍了除非清除缓存,否则Web worker不会在IE中启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的HTML5脚本中有一个非常奇怪的错误。我在OData中完全编写了一个sharepoint应用程序,它使用一些HTML 5 webworker在后台进行数字运算。这适用于所有主流浏览器(FF,IE10 + Chrome,...)。但是,当我执行刷新或再次浏览页面时。该脚本仍然可以在FF和Chrome上运行,但在IE上挂起。

I'm having a really weird bug in my HTML5 script. I wrote a sharepoint app completely in OData which uses a few HTML 5 webworker to do the number crunching in the background. This works perfect on all major browsers (FF, IE10+ Chrome, ...). However, when I perform a refresh or browse to the page again. The script still works as intended on FF and Chrome, but hangs on IE.

在我的网络视图中,我看到了一个对Worker.js文件的请求,但是有一个304未修改的回复。然后IE就挂在那个状态为(Pending)的请求上。这个问题只有在我清除浏览器缓存时才会得到解决。

In my network view I see a request for the Worker.js file, but with a 304 NOT MODIFIED response. IE then just hangs there on that request with a status of (Pending). This issue only gets resolved when I clear my browser cache.

我用self.close()正确关闭了所有线程。

I correctly close all my threads with self.close().

知道问题是什么吗?我不确定这是代码问题,浏览器问题还是服务器端问题,但我可以在线上以及本地服务器上复制Sharepoint上的错误。整个项目只是JS,所以我不能修改标题作为解决方法。

Any idea what the issue could be? I'm not sure if it's a code issue, a browser issue or a server side issue but I can replicate the bug on Sharepoint online as well as on a local server. The whole project is JS only, so I can't modify headers as a workaround either.

更新:我在sharepoint环境之外运行完全相同的代码,它工作得很好。问题是Sharepoint相关。

UPDATE: I ran exactly the same code outside of a sharepoint environment, and it worked perfectly. Issue is Sharepoint related.

推荐答案

SharePoint发送标题:

SharePoint sends the header:

Content-Disposition: attachment; filename="xyz.js"
X-Download-Options:  noopen

和IE Web Worker Implantation然后不运行此Web工作者。 (在IE11中测试)在IE网络监视器中,请求仍然处于暂挂状态,甚至可以看到响应文本。

and the IE Web Worker Implantation then does not run this web worker. (Tested in IE11) In the IE Network Monitor the request still on pending, even the Response text is visible.

我知道这样的两种解决方法:

I know so fare two workarounds:


  1. 将web worker js放在layouts文件夹中(需要一个Farm Solution,其缺点是此)

  2. 设置Web应用程序的浏览器文件处理到Permissive(可能你的安全性没有被逗乐)

这篇关于除非清除缓存,否则Web worker不会在IE中启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 14:15