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):
The reason might be that you didn't use quotes in your code: onclick=[B]"[/B]javascript:start()[B]"[/B] Code (markup):
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.
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):