I am attempting to create a page that has a webworker constantly finding gps locations.
I initiated the worker using this code:
- Code: Select all
var worker1 = new Worker('Scripts/worker1.js');
worker1.onmessage = function (event) {
alert(event.data);
};
and then in the Scripts folder, I created a js file called worker1.js which has the following code:
- Code: Select all
importScripts('http://maps.google.com/maps/api/js?sensor=true' type='text/javascript');
function sendBack(message) {
this.postMessage(message);
}
sendBack("sup");
The code without the importScripts line functions as expected, but with the line included it does not run. If I were to use the <script> tag in the index.html file, using the same url, it works fine as well. Am I not using the importScripts function properly?
its worth noting that it also does not work without the type= part removed either.
Thanks in advance!