Javascript get browser name and version
-
- Posts:4
Javascript get browser name and version
I am looking for a JavaScript that will capture the browser name and version that is understandable. I want to determine if my viewers have older IE or a browser that will not support some of the new ideas I am thinking about adding. Thanks for any help.
Admin
Posts:805
Hi
The navigator.userAgent property contains info about browser name and version.
You can use the browserCheck() function from this example to get the browser name and version in javascript:
Demo:
The navigator.userAgent property contains info about browser name and version.
You can use the browserCheck() function from this example to get the browser name and version in javascript:
Code: Select all
Click to <button id="btn_brw">Get Browser Name-Version</button>
<script>
//return an object {browser: "name", version: nr}
function browserCheck(){
var N= navigator.appName, ua= navigator.userAgent, tem;
var re= ua.match(/(opera|chrome|safari|firefox|msie|trident)\/?\s*(\.?\d+(\.\d+)*)/i);
if(re && (tem= ua.match(/version\/([\.\d]+)/i))!= null) {re[2]=tem[1];}
re= re? [re[1], re[2]]: [N, navigator.appVersion,'-?'];
return {browser:re[0], version:parseFloat(re[1])};
}
//when click on #btn_brw, get and alert browser name and version
if(document.getElementById('btn_brw')){
document.getElementById('btn_brw').addEventListener('click', function(){
var brw_nv = browserCheck();
alert('Browser: '+ brw_nv.browser +'\nVersion: '+ brw_nv.version);
});
}
</script>
Click to
dmgatwork
Posts:4
This also works great, thanks. I checked to see if the ip address was available as I had not hear of navigator but it wasn't or I could not find it.
Admin
Posts:805
From what I know, you cannot get the user's ip with javascript unless you use ajax with a server side script or some kind of external service.
Similar Topics
- Redirect according to browser type
JavaScript - jQuery - Ajax First post
Pleasant Coursesweb,Last post
I have two `simple` javascript what I wanna combine between detecting in two different browsers to script to another page....
Marplo thanks for quick feedback took me more hours, I should have come earlier with asking questions.
It is a waste I`m not have experiance with... - Hour and Minutes togheter in Javascript
JavaScript - jQuery - Ajax First post
Dear Coursesweb I can not find out how to add the hours + minutes togheter.Last post
<SCRIPT LANGUAGE= JavaScript >
day = new Date()
hr =...
See and use the following example:
<script>
var day = new Date();
let hr = day.getHours();
let mn = day.getMinutes();
let se =... - Display message to every minute in Javascript
JavaScript - jQuery - Ajax First post
Hello,Last post
On eatch minute from the current hour I wanna have an message
I can not find out how to complete
I hope to get something like this (code...
If you only want to display a message to every minute, just use the setInterval() function. It calls a function repeatedly, over and over again, at...