Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006
    Location
    Lichfield
    Posts
    4,302
    Tokens
    1,877

    Latest Awards:

    Default [JavaScript] Browser Detection?

    How would I go about this;

    I want anybody who visits my site to get a pop-up if they're not using Google Chrome.

    Is the code simple?

    Cheers

  2. #2
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    I suck at javascript, but this seems to work (haven't tested it in all browsers though):
    Code:
    if (!navigator.userAgent.indexOf("Chrome"))
    {
    	alert("Alert text here");
    }

  3. #3
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    If you are using a framework such as jQuery you can do statements such as:

    HTML Code:
    <script type="text/javascript">
    
         //$.browser.msie;
         //$.browser.mozilla;
         //$.browser.webkit;
         //$.browser.opera;
    
         if( $.browser.webkit )
         {
              alert( 'This is a webkit based browser. IE: Chrome, Safari' );
         }
    
    </script>
    More info here: http://api.jquery.com/jQuery.browser/

    Otherwise here's a slightly different version of Trinitys code that I would use:

    HTML Code:
    navigator.userAgent.toLowerCase().indexOf("chrome");
    and then obviously check it has found it etc

Posting Permissions

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