HTML and CSS Reference
In-Depth Information
appVersion //the version information of the browser
cookieEnabled //Determines whether cookies are enabled in the browser
platform //Returns for which platform the browser is compiled
userAgent //the user-agent header sent by the browser to the server
Although you can access the location object, it is read only:
hash //the anchor portion of a URL
host //the hostname and port of a URL
hostname //the hostname of a URL
href //the entire URL
pathname //the path name of a URL
port //the port number the server uses for a URL
protocol //the protocol of a URL
search //the query portion of a URL
You can use XMLHttpRequest to make AJAX calls within a worker, as well as import
external scripts using the importScripts() method, as long as they're in the same do‐
main. To cut down wait times, you can set and clear timeouts and intervals with setTi
meout() , clearTimeout() , setInterval() , and clearInterval() , respectively. Finally,
you can access the Application cache and spawn other workers. Creating a worker is
quite easy; you need only a JavaScript file's URL. The Worker() constructor is invoked
with the URL to that file as its only argument:
var worker = new Worker ( 'worker.js' );
Worker scripts must be external files with the same scheme as their
calling page. Thus, you cannot load a script from a data URL and an
HTTPS page cannot start worker scripts that begin with HTTP URLs.
The worker is not actually started until you call postMessage() , such as by sending some
object data to the worker:
worker . postMessage ({ 'haz' : 'foo' }); // Start the worker.
Next, add an EventListener to listen for data the worker returns:
worker . addEventListener ( 'message' , function ( e ) {
console . log ( 'returned data from worker' , e . data );
}, false );
In the actual worker.js file, you could have something simple like:
self . addEventListener ( 'message' , function ( e ) {
var data = e . data ;
//Manipulate data and send back to parent
self . postMessage ( data . haz ); //posts 'foo' to parent DOM
}, false );
The previous example simply relays serialized JSON from the parent DOM to the
spawned worker instance, and back again.
Search WWH ::




Custom Search