google+javascriptbanktwitter@js_bankfacebook@jsbankrss@jsbank






Sửa lỗi hiển thị PNG trong IE6 bằng JavaScript Nếu bạn là một nhà phát triển web và cho rằng đã có thể quên đi hoàn toàn các rắc rối mà IE6 đã mang lại, thì có lẽ Microsoft và người sử dụng đã làm bạn thất vọng; bởi tỉ lệ người dùng IE6 vẫn còn rất lớn. Và một trong những rắc rối khá nghiêm trọng là IE6 không hiển thị đúng các ảnh có nền trong suốt, chẳng hạn như PNG; và bài viết này sẽ hướng dẫn bạn cách khắc phục vấn đề này chỉ với JavaScript.


Nhãn: sửa lỗi, hiển thị, PNG, IE6, nhà phát triển web, rắc rối, Microsoft, nghiêm trọng, trong suốt

Miễn phí web hosting 1 năm đầu tại iPage



Nếu bạn vẫn còn đang tìm kiếm một nhà cung cấp hosting đáng tin cậy, tại sao không dành chút thời gian để thử với iPage, chỉ với không quá 40.000 VNĐ/tháng, nhưng bạn sẽ được khuyến mãi kèm với quà tặng trị giá trên 10.000.0000 VNĐ nếu thanh toán cho 24 tháng ~ 900.000 VNĐ?

Có trên 1 triệu khách hàng hiện tại của iPage đã & đang hài lòng với dịch vụ, tuyệt đối chắc chắn bạn cũng sẽ hài lòng giống họ! Quan trọng hơn, khi đăng ký sử dụng web hosting tại iPage thông qua sự giới thiệu của chúng tôi, bạn sẽ được hoàn trả lại toàn bộ số tiền bạn đã sử dụng để mua web hosting tại iPage. Wow, thật tuyệt vời! Bạn không phải tốn bất kì chi phí nào mà vẫn có thể sử dụng miễn phí web hosting chất lượng cao tại iPage trong 12 tháng đầu tiên. Chỉ cần nói chúng tôi biết tài khoản của bạn sau khi đăng ký.

Nếu muốn tìm hiểu thêm về ưu / nhược điểm của iPage, bạn hãy đọc đánh giá của ChọnHostViệt.com nhé!
Thử iPage miễn phí cho năm đầu tiên NGAY

In 2009 you'd think (and hope) that we could completely forget the problems with Internet Explorer 6. One of the issues that has caused me a lot of hassle is IE6s inability to render transparent PNG files correctly.

There are various ways to deal with IE5.5/IE6s PNG problem. I have tried several different ways of handling this situation - from using TwinHelix method, right through to serving alternative image content for IE5.5/IE6 via conditional comments and alternative stylesheets.

I've found the problem with the TwinHelix method is page load time is affected quite significantly, then serving alternative content via alternative stylesheets is a time-consuming way to handle this problem.

As I tend to use JavaScript to control various style elements that go above-and-beyond the capabilities of CSS alone, I have decided to use JavaScript to fix PNGs.

The limitation of this solution is that users who disable JavaScript will see the unfixed PNG images on their page if they are using IE5.5/IE6. However, in terms of caching and overall page speed, the small level of users browsing without JavaScript is something that I would balance in favour of a cacheable JavaScript solution to the problem.

I have been using the excellent DD_belatedPNG fix from Diller Design. All credits go to Diller Design, and to find out more please check out their site.

This easy to use method works in the following way:

1. Download the DD_belatedPNG JavaScript file (Right click > Save As). Uncompressed / Compressed. Check for latest version here.

2. Call the JavaScript file within the head section of your page as follows:

<script src="http://www.whatever.com/path/to/file/DD_belated_PNG_0.0.8a.js" type="text/javascript"></script>

3. Create a blank JavaScript file in Note Pad or an equivalent text editor and place the following code into the file, then save the file as pngfix.js:

DD_belatedPNG.fix('.png_bg');

4. In the above code replace .png_bg with any ID or class that you have applied to the image in your HTML code or in your external stylesheet. For example, if you want to apply the fix to your logo, you might give your image the class logo. This would look like the following:

<img src="http://path/to/image/file/logo.png" width="100" height="50" class="logo" />

5. If we carry on the example in step four, you would adjust the pngfix.js file as follows:

DD_belatedPNG.fix('.logo');

Other classes can be added by separating each class with a comma (I.e. DD_belatedPNG.fix('.logo, .icon, img');).

6. Now call the pngfix.js file in the head of the page below the DD_belated_PNG_0.0.8a.js file as follows:

<script src="http://www.whatever.com/path/to/file/pngfix.js" type="text/javascript"></script>

7. In the head of the page you should have the following:

<script src="http://www.whatever.com/path/to/file/DD_belated_PNG_0.0.8a.js" type="text/javascript"></script> <script src="http://www.whatever.com/path/to/file/pngfix.js" type="text/javascript"></script>

8. Now we want all other browsers to ignore the PNG fix, so we wrap the two JavaScript files in conditional comments as follows:

<!--[if lte IE 6]> <script src="http://www.whatever.com/path/to/file/DD_belated_PNG_0.0.8a.js" type="text/javascript"></script> <script src="http://www.whatever.com/path/to/file/pngfix.js" type="text/javascript"></script> <![endif]-->

Now if you test your page in IE6, you should find transparent PNGs that you have specified in the pngfix.js file are rendered correctly.

iPhoneKer.com
Save up to 630$ when buy new iPhone 15

GateIO.gomymobi.com
Free Airdrops to Claim, Share Up to $150,000 per Project

https://tooly.win
Open tool hub for free to use by any one for every one with hundreds of tools

chatGPTaz.com, chatGPT4.win, chatGPT2.fun, re-chatGPT.com
Talk to ChatGPT by your mother language

Dall-E-OpenAI.com
Generate creative images automatically with AI

AIVideo-App.com
Render creative video automatically with AI

JavaScript theo ngày


Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web