can't show img in IE ?

Discussion in 'JavaScript' started by uniojnqoifazy, Sep 8, 2011.

  1. #1
    hi all,
    i can run the function when button onclick in firefox and chrome , but why can't execute the function start() in IE?
    please someone else can help me !





    
    <script>
    function start( ) {
    			
    			var name= document.getElementById('NLoading');
    			name.innerHTML="";
    			_oTag1 = document.getElementById("nameimg");
    			_oTag1.style.display = "inline";  //Show Loading img
    			
    			var value= document.getElementById('VLoading');
    			value.innerHTML="";
    			_oTag = document.getElementById("valueimg");
    			_oTag.style.display = "inline";  //Show Loading img
    		
    		  }
    </script>
    
    <form action=""  name="form1"  method="post"    >
               <input type="button" value="Test"  name="submit"  class="groovybutton" onMouseOver="goLite(this.form.name,this.name)" onMouseOut="goDim(this.form.name,this.name)" onclick=javascript:start()>
                </form>
    
    Code (markup):
     
    Last edited: Sep 8, 2011
    uniojnqoifazy, Sep 8, 2011 IP
  2. babushkyn

    babushkyn Member

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    2
    Trophy Points:
    26
    #2
    The reason might be that you didn't use quotes in your code:

    onclick=[B]"[/B]javascript:start()[B]"[/B]
    Code (markup):
     
    babushkyn, Sep 8, 2011 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    Another possibility is that "value" is a Javascript keyword, and some versions of IE barf on that.

    Since you don't really use the variables you're declaring, just access the DOM directly.
    
    <script> 
    function start( ) {
        document.getElementById('NLoading').innerHTML="";
        document.getElementById("nameimg").style.display = "inline";  //Show Loading img
        document.getElementById('VLoading').innerHTML="";
        document.getElementById("valueimg").style.display = "inline";  //Show Loading img
    }
    </script>
    
    Code (markup):
    You could also use jQuery to make your code a lot shorter.
     
    Rukbat, Sep 8, 2011 IP
  4. hotnoob

    hotnoob Member

    Messages:
    96
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    28
    #4
    
    onclick=javascript:start()
    
    Code (markup):
    should be
    
    onclick='start();'
    
    Code (markup):
    you only need to use the javascript protocol if it is in a link, or your address bar, and when i mean javascript protocol, i mean, "javascript:"

    and as for rukbat,
    JQuery is EXTREMELY INEFFICIENT!
    that should be all that i have to say.

    if you use JQuery, you are limiting yourself so much.
    You can not effectively do crazy stuff like: http://hotnoob.com/examples/particles.html or http://hotnoob.com/examples/dfpage.php

    when you switch to JQuery, you submit to being inefficient and lazy.

    if you were to do those particle effects in JQuery, your browser would be lagging so much more.
    ---
    now if you want to have the benefits of JQuery without compromising your script's efficiency, you can do so simply by making your own useful collection of functions.

    for example:
    
    <script>
    //gei stands for Get ElementBy Id
    function gei(id)
    {
      return document.getElementById(id);
    }
    
    
    function start()
    {
        gei('NLoading').innerHTML="";
        gei("nameimg").style.display = "inline";
        gei('VLoading').innerHTML="";
        gei("valueimg").style.display = "inline";
    }
    </script>
    
    Code (markup):
     
    Last edited: Sep 11, 2011
    hotnoob, Sep 11, 2011 IP
  5. akumar2

    akumar2 Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    no idea.........sorry.....
     
    akumar2, Sep 20, 2011 IP