Navigator info

Submitted by:Jhon Jhon

Date added:24 May, 2015

Category:HTML

Shows how to access the navigator.* variables.

Tags: navigator , variables

Code Snippet:

<!------>
<script type="text/javaScript">
<!--

// dw() is just a alias for document.write()
// to make the code shorter

function dw(s){
document.write(s);
}

/*
** navigator.* values
*/

dw('<h2>
navigator.*:</h2>');

dw('navigator.appName: ' + navigator.appName);
dw('<br/>');

dw('navigator.appVersion: ' + navigator.appVersion);
dw('<br/>');

dw('navigator.userAgent: ' + navigator.userAgent);
dw('<br/>');

dw('navigator.appCodeName: ' + navigator.appCodeName);
dw('<br/>');

dw('navigator.platform: ' + navigator.platform);
dw('<br/>');

dw('navigator.cookieEnabled: ' + navigator.cookieEnabled);
dw('<br/>');

dw('navigator.javaEnabled(): ' + navigator.javaEnabled());
dw('<br/>');


/*
** Internet Explorer only
** ( these just work in IE )
*/

dw('<h2>Internet Explorer only:</h2>');

dw('navigator.userLanguage: ');
if (navigator.userLanguage){ dw(navigator.userLanguage); }
else { dw('-'); }
dw('<br/>');

dw('navigator.systemLanguage: ');
if (navigator.systemLanguage){ dw(navigator.systemLanguage); }
else { dw('-'); }
dw('<br/>');

dw('navigator.browserLanguage: ');
if (navigator.browserLanguage){ dw(navigator.browserLanguage); }
else { dw('-'); }
dw('<br/>');

/*
** Other values
*/

dw('<h2>Other values:</h2>');

dw('history.length: ' + history.length + '<br/>');
dw('Screen Resolution: '+ screen.width+'x'+screen.height+'<br/>');

/*
** Values that only work in Firefox
*/

dw('<h2>Firefox only:</h2>');

dw('navigator.language: ');
if (navigator.language){ dw(navigator.language); }
else { dw('-'); }
dw('<br/>');

/*
** Plugins (navigator.plugins -- Firefox only)
*/

dw('<h2>Plugins:</h2>');

if (navigator.userAgent.indexOf('Firefox') != -1){

dw('<table border="1">');

for (var i = 0; i < navigator.plugins.length; i++) {
dw("<tr>");
dw("<td>" + navigator.plugins[i].name + "</td>");
dw("<td>" + navigator.plugins[i].description + "</td>");
dw("<td>" + navigator.plugins[i].filename + "</td>");
dw("</tr>");
}
dw("</table>");
}
else {
dw('( Firefox only )');
}

//-->
</script>
 
 

Comments