JavaScript Window Navigator
The window.navigator
object holds details about the visitor's web browser.
Window Navigator
You can write the window.navigator
object without saying "window" before it.
Some examples:
navigator.cookieEnabled
navigator.appCodeName
navigator.platform
Browser Cookies
The property called cookieEnabled
tells us whether cookies are turned on or off. If it's true, then cookies are enabled, but if it's false, then they're not:
Browser Application Name
The appName
property tells you the name of the browser's application.
Warning
This feature is no longer supported in the newest web rules.
Most internet browsers like IE11, Chrome, Firefox, and Safari show "Netscape" as the application name.
Browser Application Code Name
The appCodeName
shows what the browser's code name is.
The Browser Engine
The product
feature gives you the name of the browser engine.
The Browser Version
The appVersion
tells us which version of the browser we're using.
The Browser Agent
The code userAgent
shows the info the browser sends to the server.
Warning
The data from the navigator object might not always give the right picture.
The navigator object shouldn't be used to figure out what browser version you have because:
- Various web browsers are able to employ identical identifiers.
- The information the browser uses can be altered by the person who owns the browser.
- Some web browsers pretend to be different to get around website checks.
- Web browsers can't tell you about operating systems that come out after the browser was made.
The Browser Platform
The platform
feature gives the type of operating system used by the browser.
The Browser Language
The language
object tells us what language the browser is using.
Is The Browser Online?
The onLine
object tells us if the browser is connected to the internet or not.
Is Java Enabled?
The javaEnabled()
function tells us if Java is turned on.
<!DOCTYPE html>
<html>
<body>
<h2>The Navigator Object</h2>
<p>The "cookieEnabled" thingy tells you if cookies are okay to use.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "navigator.cookieEnabled is " + navigator.cookieEnabled;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>The Navigator Object</h2>
<p>The "appName" feature tells you the name of the browser you're using.</p>
<p id="demo"></p>
<p>Surprisingly, "Netscape" is what they call IE11, Chrome, Firefox, and Safari.</p>
<script>
document.getElementById("demo").innerHTML = "navigator.appName is " + navigator.appName;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Navigator</h2>
<p>The appCodeName feature tells you the special name of the web browser you're using.</p>
<p>Don't depend on it! 'Mozilla' is the code name for applications like Chrome, Firefox, Internet Explorer (IE), Safari, and Opera.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "navigator.appCodeName is " + navigator.appCodeName;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>The Navigator Object</h2>
<p>The product property returns the product name of the browser.</p>
<p>Don't count on it! Many web browsers will show 'Gecko' as the product name!</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "navigator.product is " + navigator.product;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>The Navigator Object</h2>
<p>The appVersion property tells us which version of the browser we're using.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = navigator.appVersion;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>The Navigator Object</h2>
<p>The userAgent attribute shows the user-agent header the browser sends to the server.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = navigator.userAgent;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>The Navigator Object</h2>
<p>The "platform" property tells you what operating system your browser is using.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "navigator.platform is " + navigator.platform;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>The Navigator Object</h2>
<p>The language property returns the browser's language:</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "navigator.language is " + navigator.language;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>The Navigator Object</h2>
<p>The "onLine" feature tells us if the browser is connected to the internet or not.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "navigator.onLine is " + navigator.onLine;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h2>The Navigator Object</h2>
<p>The javaEnabled() function tells us if Java is turned on or off.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "javaEnabled is " + navigator.javaEnabled();
</script>
</body>
</html>