It's very simple but I don't know JS

Discussion in 'JavaScript' started by jonhyhar, Dec 14, 2010.

  1. #1
    Hello guys, I'm new at JS, I just have a quick question,
    what's wrong with this code?

    
    		abc = window.location;
    		if(abc == ""){
    		ivir = 0;
    		}	
    
    		if(ivir == 0){
    		alert("no url!")
    		}else{
    		alert("you are at" + abc)
                    }
    
    Code (markup):
    thank you all :confused:
     
    jonhyhar, Dec 14, 2010 IP
  2. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #2
    Try this :
    
    <script>
        var abc = window.location.href;
        if(abc.length == 0)
        {
            alert("no url!");
        } else {
            alert("you are at :" + abc);
        }
        </script>
    
    HTML:
     
    tvoodoo, Dec 14, 2010 IP
    jonhyhar likes this.
  3. jonhyhar

    jonhyhar Active Member

    Messages:
    166
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    work very good tvoodoo, thank you very much :)
     
    jonhyhar, Dec 14, 2010 IP
  4. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #4
    You're welcome
     
    tvoodoo, Dec 14, 2010 IP