zoukankan      html  css  js  c++  java
  • IE显示PNG

     JS代码:

    var IE = (document.all) ? true : false

     
    function correctPNG(img) // correctly handle PNG transparency in Win IE 5.5 or higher.       
     {       
         
    if (IE)
         
    {               
             
    var imgName = img.src.toUpperCase()       
             
    if (imgName.substring(imgName.length-3, imgName.length) == "PNG")       
             
    {       
                 
    var imgID = (img.id) ? "id='" + img.id + "" : ""      
                 
    var imgClass = (img.className) ? "class='" + img.className + "" : ""      
                 
    var imgTitle = (img.title) ? "title='" + img.title + "" : "title='" + img.alt + ""      
                 
    var imgStyle = "display:inline-block;" + img.style.cssText       
                 
    var imgAttribs = img.attributes;       
                 
    for (var j=0; j<imgAttribs.length; j++)       
                 
    {       
                     
    var imgAttrib = imgAttribs[j];       
                     
    if (imgAttrib.nodeName == "align")       
                     
    {       
                         
    if (imgAttrib.nodeValue == "left") imgStyle = "float:left;" + imgStyle       
                         
    if (imgAttrib.nodeValue == "right") imgStyle = "float:right;" + imgStyle       
                         
    break      
                     }
           
                 }
           
                 
    var strNewHTML = "<span " + imgID + imgClass + imgTitle       
                 strNewHTML 
    += " style=\"" + "" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"      
                 strNewHTML += 
    "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"      
                 strNewHTML += 
    "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"      
                 img.outerHTML 
    = strNewHTML  

             }
           
         }
           
     }
     


    使用:

    <Head>标签间插入 <script language="javascript" type="text/javascript" src="path/Png.js"></script> 

     <body>

    <img src="" onload="correctPNG(this);" />

     ...

    </body>

  • 相关阅读:
    <转>使用IdentifyTask查询图层属性
    转:Java+blazeds+Flex的例子 .
    转 ArcGIS Runtime 加载SHAPE数据的另一种方式动态图层 .
    序列密码之A5
    哈希函数之MD5
    DjangoRestFramework使用总结
    公钥密码之RSA
    Request Line is too large (xxxx > 4094) 问题处理
    古典密码之仿射密码
    Linux重定向
  • 原文地址:https://www.cnblogs.com/zzh/p/1249020.html
Copyright © 2011-2022 走看看