503b306173879b6efd6ad8ff9ce094da515f380f
[lhc/web/wiklou.git] / stylesheets / IEFixes.js
1 // IE fix javascript
2
3 // png alpha transparency fixes
4 window.attachEvent("onload", fixalpha);
5
6 function fixalpha(){
7 // bg
8 var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
9 if (rslt != null && Number(rslt[1]) >= 5.5)
10 {
11 for (i=0; i<document.all.length; i++){
12 var bg = document.all[i].currentStyle.backgroundImage;
13 if (bg){
14 if (bg.match(/\.png/i) != null){
15 var mypng = bg.substring(5,bg.length-2);
16 document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='image')";
17 document.all[i].style.backgroundImage = "none";
18 }
19 }
20 }
21 // img
22 for(var i=0; i<document.images.length; i++)
23 {
24 var img = document.images[i]
25 var imgName = img.src.toUpperCase()
26 if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
27 {
28 var imgID = (img.id) ? "id='" + img.id + "' " : ""
29 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
30 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
31 var imgStyle = "display:inline-block;" + img.style.cssText
32 if (img.align == "left") imgStyle = "float:left;" + imgStyle
33 if (img.align == "right") imgStyle = "float:right;" + imgStyle
34 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
35 var strNewHTML = "<span " + imgID + imgClass + imgTitle
36 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
37 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
38 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
39 img.outerHTML = strNewHTML
40 i = i-1
41 }
42 }
43 }
44 }