admin管理员组文章数量:1279090
I'm trying to create a HTML5 Web Worker in phonegap, but phonegap doesn't allow me to load a local javascript file at runtime. I get the following error:
var web_worker=new Worker('socket-worker.js')
undefined
file://socket-worker.jsFailed to load resource: The requested URL was not found on this server.
Does anyone have a good suggestion on how I can work around this, and get the worker running?
Thanks!
I'm trying to create a HTML5 Web Worker in phonegap, but phonegap doesn't allow me to load a local javascript file at runtime. I get the following error:
var web_worker=new Worker('socket-worker.js')
undefined
file://socket-worker.jsFailed to load resource: The requested URL was not found on this server.
Does anyone have a good suggestion on how I can work around this, and get the worker running?
Thanks!
Share Improve this question asked Apr 19, 2013 at 16:09 asprotteasprotte 1,1011 gold badge9 silver badges12 bronze badges 3- 1 there's absolutely no problem with PhoneGap loading files at runtime. Check your filepath, try with absolute path once. – SHANK Commented Apr 20, 2013 at 10:53
- @asprotte - were you able to use webworkers from phonegap? – murtaza52 Commented Jun 14, 2013 at 7:07
- Thank you SHANK. You were right, the problem was not with loading the file. @murtaza52 yes, the problem wasn't actually with the socket-worker.js file but due to the method i was importing the js library socket.io in my socket-worker.js using importScripts(). Instead of importing the socket.io script locally I had to load in it with an http request: importScripts('someaddress/socket.io.js') – asprotte Commented Jun 17, 2013 at 13:23
2 Answers
Reset to default 9Haven't tried this yet but I believe we can run it using blob url. See it here ( http://www.html5rocks./en/tutorials/workers/basics/#toc-inlineworkers-bloburis )
Update: I've tried this already and it worked. :)
As per my knowledge Web Workers never works on local directory
file://
it works on server side. For example instead of placing files at "file://" so the path should be
***> http://localhost/ or***
***> http://server_ip_address***
Hence Phonegap consists of HTML and Javascript which are at device directory hence web workers are not supported in Phonegap.
本文标签: javascriptUsing web workers in phonegapStack Overflow
版权声明:本文标题:javascript - Using web workers in phonegap - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741220056a2360796.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论