Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Apr 2009
    Thanked 1 Time in 1 Post

    Please help: Can't get my get_os function to work..

    Hi everybody. I've been doing some research on a function I've created using alot of data gathered from google. I need some help on the function b/c I have tried everything and to no avail. What I need help with is to be able to get the name AND version of ANY browser, reguardless of if it is a fake user agent or not. Like for example, if you wanna find out if someone is on Firefox, it would say: Mozilla Firefox x.x where x.x = version. It will be used in my security code for PHP that I made.

    Do you see this line? "if (/navigator.userAgent (\d+\.\d+);/.test(navigator.userAgent)){ //test for ANY browser" ?

    Well I need it to test for ANY browser, using useragent.

    Heres the code:

    /*This code is free for use as long as this header remains in contact
    //Created by ShadowIce
    //You may not change, steal, or delete this code without permission from the author
    //Created on: Thursday, May 14th, 2009 | 10:32 AM
    function get_os(){
    var ua = navigator.appName; //navigator.userAgent; //.toLowerCase();
    var thebrowser = ua;
    var browser = thebrowser;
    var b_version=navigator.appVersion;
    //var version=parseFloat(b_version);
    //var ver = version;
    var os = browser;
    if (/navigator.userAgent (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
     var version=new Number(RegExp.$1) // capture x.x portion and store as a number
    //}else if(/Mozilla (\d+\.\d+);/.test(navigator.userAgent)){
    // var version=new Number(RegExp.$1) // capture x.x portion and store as a number
    browser = os+" "+version;
    return browser;
    document.write('You are on '+get_os());

    Last edited by ShadowIce; 05-15-2009 at 01:55 AM.


Posting Permissions

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