Saturday 23 September 2017

Get Browser Name and OS Name using Jquery.

This article tells about whenever we browse any kind of page then in the page itself we can find out Browser name and OS name of Users using Jquery.

Well to get the Browser Name and OS Name we will use some plugin which is already present in GitHub and for more information you can follow this link: https://github.com/Pagawa/PgwBrowser

At First take a page, and include Jquery in head section of that page because as we are using Jquery so compulsory we need to include Jquery as a reference otherwise it will show you an error like, "Uncaught ReferenceError: $ is not defined".

After that download pgwbrowser.min.js or pgwbrowser.js file from this github link : https://github.com/Pagawa/PgwBrowser and also you need to add pgwbrowser.min.js or pgwbrowser.js file in your Page as a reference.

After that we will write some code in Jquery which is as follows,

 <script type="text/javascript">
        $(document).ready(function () {            
            var pgwBrowser = $.pgwBrowser();
            var browsername = pgwBrowser.browser.name;
            var osname=pgwBrowser.os.name;
        });
 </script>

Here you can get the BrowserName and OSName but if you want more information of browser like version etc then please see the below image and you can implement the same in your code also.


0 comments:

Post a Comment