Jump to content

Javascript from IE


suzie

Recommended Posts

Dear,am using in my site done in php, the following javascript function (showcollapse)...In Fire Fox it works very well, but in explorer it doesn't work....(IE 8)here is the function:<script type="text/JavaScript">function showcollapse(what){a=document.getElementById(what);if (a.style.display==''){a.style.display='none';} else {a.style.display='';}}</script>and here is the call...<div class="class1"><a href="java script:showcollapse('1');">$title</a></div>and the error is in the line:a=document.getElementById(what);object doesn't support this property or methodplease any Help!!Best Regards, thank you

Link to comment
Share on other sites

IDs can't start with numbers. That is the standard (Firefox is just being nice to you).

Link to comment
Share on other sites

Also, you should really be declaring the a variable with the var keyword.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...