[RESOLVED] Javascript in Firefox - doctype problem - id not defined?
Hello,
I really need some help. I have been struggling with this script all day and haven't found any solution.
<script type="text/javascript">
function toggleButton(ktory,ile,id_obrazka,f,q) {
for (i=0; i<ile; i++) {
eval('wybor'+i).className='';
}
if (document.getElementById) {
eval(document.getElementById('wybor'+ktory)).className = 'active';
document.getElementById(id_obrazka).setAttribute('src',f + q+'.jpg')
}
else if (document.all) {
eval(document.all['wybor'+ktory]).className = 'active';
document.all[id_obrazka].setAttribute('src',f + q+'.jpg')
}
}
</script>
<img id="wywiady" src="22.jpg"></td>
<a class="active" id="wybor0" href= "#" onMouseOver="toggleButton(0,2,'wywiady','/zawodnicy/images/mini/','22')"> test 1 </a><BR/>
<a class="" id="wybor1" href= "/news.html?pokaz_news=10554" onmouseover="toggleButton('1','2','wywiady','/zawodnicy/images/mini/','55')" > test 2</a>
The problem is that it stops working at all in Firefox with the DoCTYPE declaration <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> (or strict). It works only when I run it without any declaration or <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">. The script works in every other browser tested in each of those DOCtypes.
I also found out that the webdeveloper tool in FF shows 'wybor0 is not defined'. What can it be?
Bookmarks