Javascript is the programming language of the web.Javascript has changed our vision to the web.when the web started with Html and CSS .visitor can only watch and read without any interaction with the javascript , we have hundreds of things that we can do with a web page especially with the new javascript frameworks.browser.But , after the invention of
In this tutorial, I want to concentrate on the navigator object which has an interesting methods to analyse the browser properties and even access to some computer settings.
Access to the browser properties :
With javascript, you can extract the name of the browser , the version ...etc .Let's try this.1-Browser name :
The property that display the browser name as a String is appCodeName ,Example :
Demo:
2-Browser Language :
Javascript is capable to access the browser language and display the first two characters as a String , for example , if the language is english , then the result become : "en" , if french : "fr" ...the navigator property is simply : language . let's try the following script :
Demo :
3-Testing java and Cookies :
Using javascript , we can test if java is enabled in the browser or not. using the method javaEnabled() which return a Boolean value : false if java is not enabled , true if enabled.Demo :
Testing browser cookie is very easy like for java , but be careful , in this case we use the property cookieEnabled not a method like for java.
4-Browser Plugins :
The navigator property plugins , return an Array of the installed plugins in your browser ,The following example display the number of plugins installed in your browser :
Access Battery through Javascript :
Javascript contain a useful collection of methods and properties that can access the battery of your computer through the battery object.Battery level :
Access the battery level can be performed using the level property : navigator.battery.level which return a number from 0 to 1 , if your battery is full charged it will return 1 .let's try this :Demo:
Charging status :
javascript can test whether your charger is connected or not through the charging property.return a true if the charger is connected and false if not.Demo :







0 comments
Posts a comment