internet explorer 8 - is null or not an object in IE8/7 by using javascript -


the javascript this:

    <script type="text/javascript"> var links = document.getelementbyid("practice_nav_var_color"); var = links.getelementsbytagname("a"); var thislocationhref = window.location.href; for(var i=0;i<a.length;i++){     var templink = a[i];          if(thislocationhref === templink.href)   {       templink.style.backgroundcolor="#7387a2";   }   else   {       templink.style.backgroundcolor="#8d8679";   } } 

in ie8, error message says "links" null or not object.
first guess ie doesn't document.getelementbyid...

i have searched online, seems has conditional statements previous div, not sure mean.

any welcome. thank time!

try this

var links = document.getelementbyid("practice_nav_var_color"); if(links) {     var = links.getelementsbytagname("a");     var thislocationhref = window.location.href;     for(var i=0;i<a.length;i++){             var templink = a[i];                if(thislocationhref === templink.href)         {             templink.style.backgroundcolor="#7387a2";         }         else         {             templink.style.backgroundcolor="#8d8679";         }     } } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -