Showing posts with label How to get browser information using jQuery. Show all posts
Showing posts with label How to get browser information using jQuery. Show all posts

Monday 3 November 2014

How to get browser name using jQuery


How to get browser name using jQuery

Here, I am explaining how to know about the browser name using jquery. We can find out lots of information about browser like its name, version using jquery. To access $.browser property in jquery 1.9+ versions, we can use jquery migrate plugin.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>

<script type="text/javascript" > 
$(document).ready(function(){
var browser;
if($.browser.mozilla)
browser = "Firefox";
else if($.browser.msie)
browser = "Internet Explorer";
else if($.browser.opera)
browser = "Opera";
else if($.browser.safari)
browser = "Safari";
else
browser = "Unknown";
$('#browserName').append(browser);
});
</script> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Get Browser Name</title>
</head>

<body>
<div id="browserName"> Your Browser Name : </div> 
</body>
</html>