Micro Niche Builder
Closed Thread
Results 1 to 3 of 3

Thread: Detecting browser using javascript

  1. #1

    Default Detecting browser using javascript

    Hello

    i am using php and I want to detect browser using javascript , is it possible to detect browser of the client using javascript?


  2. SEO Software

  3. #2

    Default

    Code:
    <html>
    <body>
    
    <script type="text/javascript">
    var browser=navigator.appName;
    var b_version=navigator.appVersion;
    var version=parseFloat(b_version);
    
    document.write("Browser name: "+ browser);
    document.write("<br />");
    document.write("Browser version: "+ version);
    </script>
    
    </body>
    </html>

  4. #3
    Mr. BindasS ankur0412 is on a distinguished road ankur0412's Avatar
    Join Date
    Feb 2009
    Location
    India
    Posts
    717
    Thanks
    24
    Thanked 55 Times in 42 Posts
    Blog Entries
    2

    Default

    below is a general code for detecting browsers. It even detects the operating system...
    you can use it to optimize your site for different browsers also..

    <!-- Code for browser detect starts here -->
    var BrowserDetect = {
    init: function () {
    this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
    this.version = this.searchVersion(navigator.userAgent)
    || this.searchVersion(navigator.appVersion)
    || "an unknown version";
    this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function (data) {
    for (var i=0;i<data.length;i++) {
    var dataString = data[i].string;
    var dataProp = data[i].prop;
    this.versionSearchString = data[i].versionSearch || data[i].identity;
    if (dataString) {
    if (dataString.indexOf(data[i].subString) != -1)
    return data[i].identity;
    }
    else if (dataProp)
    return data[i].identity;
    }
    },
    searchVersion: function (dataString) {
    var index = dataString.indexOf(this.versionSearchString);
    if (index == -1) return;
    return parseFloat(dataString.substring(index+this.version SearchString.length+1));
    },
    dataBrowser: [
    {
    string: navigator.userAgent,
    subString: "Chrome",
    identity: "Chrome"
    },
    { string: navigator.userAgent,
    subString: "OmniWeb",
    versionSearch: "OmniWeb/",
    identity: "OmniWeb"
    },
    {
    string: navigator.vendor,
    subString: "Apple",
    identity: "Safari",
    versionSearch: "Version"
    },
    {
    prop: window.opera,
    identity: "Opera"
    },
    {
    string: navigator.vendor,
    subString: "iCab",
    identity: "iCab"
    },
    {
    string: navigator.vendor,
    subString: "KDE",
    identity: "Konqueror"
    },

    {
    string: navigator.vendor,
    subString: "Camino",
    identity: "Camino"
    },
    {
    string: navigator.userAgent,
    subString: "Firefox",
    identity: "Firefox"
    },
    { // for newer Netscapes (6+)
    string: navigator.userAgent,
    subString: "Netscape",
    identity: "Netscape"
    },
    {
    string: navigator.userAgent,
    subString: "MSIE",
    identity: "Explorer",
    versionSearch: "MSIE"
    },
    { // for older Netscapes (4-)
    string: navigator.userAgent,
    subString: "Mozilla",
    identity: "Netscape",
    versionSearch: "Mozilla"
    }
    ],
    dataOS : [
    {
    string: navigator.platform,
    subString: "Win",
    identity: "Windows"
    },
    {
    string: navigator.platform,
    subString: "Mac",
    identity: "Mac"
    },
    {
    string: navigator.userAgent,
    subString: "iPhone",
    identity: "iPhone/iPod"
    },
    {
    string: navigator.platform,
    subString: "Linux",
    identity: "Linux"
    }
    ]

    };
    BrowserDetect.init();

Closed Thread

Similar Threads

  1. What is the best browser?
    By Monk in forum SEO Forum
    Replies: 167
    Last Post: 04-04-2012, 10:54 PM
  2. Do you know the browser Sougou?
    By coly20032003 in forum SEO Forum
    Replies: 17
    Last Post: 03-15-2010, 04:54 PM
  3. Editing pics in your browser alone
    By Kay in forum Graphics
    Replies: 5
    Last Post: 03-29-2009, 12:18 PM
  4. Browser PPC banner required
    By Valmar in forum Pay Per Click (PPC)
    Replies: 0
    Last Post: 03-28-2009, 06:43 PM
  5. Browser detection help
    By nikon in forum JavaScript Help
    Replies: 2
    Last Post: 02-13-2009, 01:51 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts