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 6 of 6
  1. #1
    Join Date
    Nov 2006
    Location
    Leeds, Yorkshire
    Posts
    992
    Tokens
    0

    Default javascript - show something on page

    right I have this:

    Code:
    <script>
    if(navigator.userAgent.indexOf("Firefox") != -1)
    {
       alert ("your using firefox")
    }
    else
    {
       alert ("your not using firefox")
    }
    </script>
    is there any way I could get it to display some text in a div onto the page instead of an alert?

    thanks


  2. #2
    Join Date
    Nov 2005
    Posts
    807
    Tokens
    1,335

    Latest Awards:

    Default

    Yup.. just place this into your body:
    HTML Code:
    <div id="browser"></div>
    and change your script to this:
    HTML Code:
    <script>
    if(navigator.userAgent.indexOf("Firefox") != -1)
    {
      document.getElementById("browser").innerHTML = 'Your using firefox!'
    }
    else
    {
      document.getElementById("browser").innerHTML = 'Your not using firefox!'
    }
    </script>

  3. #3
    Join Date
    Nov 2006
    Location
    Leeds, Yorkshire
    Posts
    992
    Tokens
    0

    Default

    I get this:


  4. #4
    Join Date
    Nov 2005
    Posts
    807
    Tokens
    1,335

    Latest Awards:

    Default

    What are you testing it in?? :S Should work in just a html file.. :S

  5. #5
    Join Date
    Nov 2006
    Location
    Leeds, Yorkshire
    Posts
    992
    Tokens
    0

    Default

    Frontpage. But when I open it in firefox and IE I just get blank pages.


  6. #6
    Join Date
    Nov 2005
    Posts
    807
    Tokens
    1,335

    Latest Awards:

    Default

    Was the previous script working.. also try:
    HTML Code:
    <script type="text/javascript">
    if(navigator.userAgent.indexOf("Firefox") != -1)
    {
      document.getElementById("browser").innerHTML = 'Your using firefox!'
    }
    else
    {
      document.getElementById("browser").innerHTML = 'Your not using firefox!'
    }
    </script>

Posting Permissions

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