Javascript Problem!
-
Hi everyone, I have an Asp.net that has some Javascripts and so when I use the ie png transparency hacks, this scripts would not work correctly so wrote this for myself:
var elements = document.body.all[i]; for(i = 0; i < elements.length; i++){ var element = elements[i]; if(element.style.backgroundImage){ var BackgroundImage = new String(); BackgroundImage = element.style.backgroundImage; if(BackgroundImage.toLowerCase().indexOf('.png',0) != -1){ var ImageAddress = new String(); ImageAddress = BackgroundImage.substr(BackgroundImage.toLowerCase().indexOf('(',0), BackgroundImage.toLowerCase().indexOf(')',0) - 1); element.style.backgroundImage = 'none'; ImageAddress = ImageAddress.substring(1,ImageAddress.length - 1); element.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + ImageAddress + '\', sizingMethod=\'scale\');'; } } }
It works nice and fixes the png transparency in ie but when it runes and does it's job, the page elements like buttons and even the onclick events of the td tags seems to be disabled and do not response! I tried to find the problem point and I tested some different codes and I achieved the point makes this problem. I started testing different tags like this:var elements = document.body.getElementsByTagName("table"); for(i = 0; i < elements.length; i++){ var element = elements[i]; if(element.style.backgroundImage){ var BackgroundImage = new String(); BackgroundImage = element.style.backgroundImage; if(BackgroundImage.toLowerCase().indexOf('.png',0) != -1){ var ImageAddress = new String(); ImageAddress = BackgroundImage.substr(BackgroundImage.toLowerCase().indexOf('(',0), BackgroundImage.toLowerCase().indexOf(')',0) - 1); element.style.backgroundImage = 'none'; ImageAddress = ImageAddress.substring(1,ImageAddress.length - 1); element.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + ImageAddress + '\', sizingMethod=\'scale\');'; } } }
And I found out that when it goes this way:var elements = document.body.getElementsByTagName("td"); for(i =