Help with this javascript code and CSS styling.

Discussion in 'HTML & Website Design' started by saadi123, Apr 14, 2010.

  1. #1
    I was just practicing javascript when I encountered this code. First I will type the code and then will tell you about the problem.

    starting right from the main code and eliminating all the necessary tags.

    function GetVersion()
    {
    var place=0
    place=navigator.appVersion.indexOf(" ")
    return (navigator.appVersion.substring(0,place))
    }
    document.write ("<h2>you are running navigator")
    document.write (" version " + GetVersion() + "</h2>")

    Of course this code will display the navigator version I am using. In my case it's navigator version 5.0.

    My question is that how the indexOf(" ") method is returning the navigator version? because the purpose of indexOf() method is just to return the position of string. Or in simple words please explain the purpose of the code in the next two lines right after var place=0.

    Now coming to CSS styling. I created a simple blog template. When I tried to type in the characters, the extra characters won't shift to the new line unless I use the <p></p> tags. I think it has something to do with the overflow property. However tell me the way in which I can set my blog so that it starts accomodating extra characters to the new line automatically without even using <p></p> tags. Just like in any wordpress or blogger blog.

    I hope you understand.
     
    saadi123, Apr 14, 2010 IP
  2. saadi123

    saadi123 Well-Known Member

    Messages:
    196
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #2
    Hey..!!! has every one in this forum gone for vacations?????
     
    saadi123, Apr 15, 2010 IP
  3. weaverIT

    weaverIT Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Navigator App version will be usually e: 4.75 [en] (Win98; U)]
    The javascript function find out the occurence of first space ie index of first space ...since space is the separator in the string "e: 4.75 [en] (Win98; U)]" with space as separator...and then reurns the substring starting from zeroth index to index of first space index
    Thus returns the appvesion number
    Hope this helps
     
    weaverIT, Apr 18, 2010 IP
  4. saadi123

    saadi123 Well-Known Member

    Messages:
    196
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #4
    Yeah thanks weaverIT. that really helped.
     
    saadi123, Apr 19, 2010 IP