PNG 파일을 웹에 사용하기...

참 어려운 문제입니다.

아직 국내의 대부분의 유저는 IE6 을 사용하고 있으며, 이 버전에는 PNG파일을 제대로 지원을 하지 않기에 웹에 PNG파일을 사용하기 위해서는 별도로 스크립트를 붙여줘야 합니다.
어려운 작업은 아니지만, 이 스크립트로 인해 웹 로딩 속도가 줄어드는 단점이 있어 선듯 사용하기 쉽지 않은게 사실입니다.

현재 올댓오카리나 유저의 50% 가 IE6을 사용하고 있으며, 이 수치는 약 1년전과 비교했을때 70% 육박하던 사용자 비율에서 많이 감소하긴 하였습니다. IE7과 IE8 버전 덕분에 앞으로도 계속 IE6 사용자는 지속적으로 줄어들 전망입니다. (특히 이번에 발표된 Windows7의 역활이 클것으로 예상합니다.)



IE 6 이전 버전에 투명 PNG파일을 적용시키기 위한 스크립트.

This method does no checking for deprecated  img align="left" or align="right" attributes. It also breaks the non-invasive JS principal somewhat in that it is specifically called by selected PNG images on load in all JS-supporting browsers. However, while the function is called in all browsers, it only actually does something in IE 5.5 and 6.

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage)
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters))
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
       var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
       var imgTitle = (myImage.title) ?
                     "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
       var imgStyle = "display:inline-block;" + myImage.style.cssText
       var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width
                  + "px; height:" + myImage.height
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
       myImage.outerHTML = strNewHTML     
    }
}

To implement this only on specific PNGs, add the following to each PNG image you wish to transform:

<img src="xyz.png" alt="foo" width="10" height="20" onload="fixPNG(this)">

NB: You must have height and width attributes specified.

출처 : http://homepage.ntlworld.com/bobosola/pnginfo.htm

Unit PNG Fix

Waaaaah! Waaaaaah! You hear that? That’s IE6 whining about how you should be using an obtuse “filter” attribute, causing all those nice, pretty pngs on your page to go whacky. Fortunately for you, we got just the thing to shut it up. Give it just the tiniest dose of our Unit PNG Fix and bask in the the glorious phosphoresence of your png images once again! While this is not the only png fix out there (in fact, it was inspired by Drew McLellan’s supersleight), here’s why it will be the last one you need to download:


Very compact javascript: Under 1kb!
Fixes most interactivity problems caused by IE’s filter attribute.
Works on img objects and background-image attributes.
Runs automatically. You don’t have to define classes or call functions.
Allows for auto width and auto height elements.
Super simple to deploy.

Go ahead and download the zip. Go ahead, it won’t bite. Then add the following code to your header [make sure the paths reflect your folder structure]:

<!--[if lt IE 7]>
        <script type="text/javascript" src="unitpngfix.js"></script>
<![endif]-->



출처 : http://labs.unitinteractive.com/unitpngfix.php

Posted by 임경희


Trackback URL : http://ocarinacenter.com/blog/trackback/27

« Previous : 1 : ... 125 : 126 : 127 : 128 : 129 : 130 : 131 : 132 : 133 : ... 153 : Next »

블로그 이미지

올댓오카리나의 관리자이며, 오카리니스트 임경희의 개인 블로그입니다.

- 임경희

Calendar

«   2012/05   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31