The Daily Click ::. Forums ::. General Chat ::. PNG test site
 

Post Reply  Post Oekaki 
 

Posted By Message

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
11th January, 2005 at 14:04:12 -

Hiya, just a quicky-

I'm planning on using alpha PNG files in a new site design of mine, and I'm incorporating a little fix to let IE view the transparency.

Browser compatability isn't my greatest concern, so I only really test in recent versions of IE (generally 5 or higher, unless I can find a PC with version 4 installed) and Firefox. Amongst people I know, I've found these are the only brands of browser they use. I've tested this script in IE6 and Firefox 0.9, and it works perfectly in both.

But I'd appreciate it if you could all quickly check that the page works on your browser too?

http://www.snorland.com/~robbie/harrington/template/pngtest/test.html

Please, if you have browsers other than Firefox and IE, I especially would like you to test this.

Thanks ever so much!

 
191 / 9999 * 7 + 191 * 7

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
11th January, 2005 at 14:15:01 -

Works fine in FF and IE. Nice fix! Didn't think it could be done.

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

jast



Registered
  03/01/2014 01:12:19
Points
  186
11th January, 2005 at 14:53:04 -

1. My status bar only displays "done", not what you said it would display

2. The picture does blend with the background - however, it doesn't do it perfectly on the right hand side. Although I guess it's just an imperfect alpha channel, I thought I should let you know since that was what you asked for

3. Don't you use blue on red!?!

4. I'm using FF 1.0

 
n/a

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
11th January, 2005 at 14:58:35 -

Firefox 1.0: Statusbar says "Done", Immage appears correctly.

IE6: Statusbar says "IE is using PNG filter". No image appears at all, it's all just a red background. However right clicking where the image should be still has the "Save picture as..." etc. menu.

 
- Tigerworks

醤油の兵士

Almost Human

Registered
  12/06/2002
Points
  173

VIP Member
11th January, 2005 at 15:22:45 -

well, I've completly disabnled IE on my computer, so I won't test it there. Works fine in FF though, and will work fine in Opera, Mozilla, and Netscape too, IE just plain sucks, doesn't it

 
As a boy, I wanted to be a train. I didn’t realize this was unusual—that other kids played with trains, not as them.

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
11th January, 2005 at 15:26:57 -

Works with IE (and FF) on my PC. I heard about using DirectX to fix that before, but I never saw anyone actually try and use it.

 
n/a

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
11th January, 2005 at 15:31:39 -

Works for me on FF1.0 & IE6.0, but in FF1.0 is just says Done in the bottom left hand corner like it does every other page after its loaded.

 
http://www.facebook.com/truediamondgame

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
11th January, 2005 at 16:25:52 -

Hmm, it's odd that Tigsy's IE6 isn't showing it up. It sounds like the PNG filter simply isn't working for him, and I dunno why that could be. Maybe some kind of security setting has disabled it?

The status thing in Firefox 1.0 doesn't bother me too much, that's mainly to determine whether the browser is trying to kid Javascript into thinking it's IE when it isn't (apparently some do that). If it says 'IE is using PNG filter' and you aren't using IE, then you know your Browser's telling porkies

The way the page works is based on a fix from Microsoft involving CSS filters.

The page starts off with a IMG tag where SRC is the address of the PNG file. But it also has a CSS style telling it to show that same PNG file using a filter.

If you view the page in Firefox, it won't understand the filter, so it just ignores it. Then it will draw the SRC png file the same way it always does - perfectly, complete with alpha transparency. This is what most browsers should do.

If you view the page in Internet Explorer, then CSS runs the filter and draws the PNG properly. However, the next thing IE will try doing is drawing the PNG itself - not only will this IE-generated PNG picture not have transparency, but it will put it ON TOP OF our pretty CSS picture. So to stop it doing this, a javascript changes the src attribute so that it points to a transparent gif file instead. This way, IE draws the gif instead, and we can see straight through it to reveal the nice css picture underneath.

Not nearly as complicated as it sounds


 
191 / 9999 * 7 + 191 * 7

Pete Nattress

Cheesy Bits img src/uploads/sccheesegif

Registered
  23/09/2002
Points
  4811
11th January, 2005 at 16:27:53 -

works fine with FF1.0 and IE 6.0.2900 SP2. cool fix!

 
www.thenatflap.co.uk

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
11th January, 2005 at 17:08:41 -

Cool!

Although you know what I said about some browsers pretending to be IE when they're not? Well Opera is one of 'em, it turns out!

But not many people use it, so I'm happy enough with it mainly working in Firefox, Netscape and IE6

 
191 / 9999 * 7 + 191 * 7

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
11th January, 2005 at 17:46:54 -

works in Netscape=works on safari. woo!

ps. works for me (IE6, SP2, most recent IE version)

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
11th January, 2005 at 18:15:10 -

Mac IE has good PNG support, so you wouldn't want it running on that. (How many people actually use IE on Mac anyway?)

 
n/a

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
11th January, 2005 at 19:00:27 -

Hardly anyone here uses Mac if you can recall the old Mac bash post a while back. Anyway, they did do alot of fixing to the IESP2, but FireFox is still alot better.

 
http://www.facebook.com/truediamondgame

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
12th January, 2005 at 12:07:16 -

Sorry Dines! Turned out I'm using IE5. I used to have IE6, but I recently reinstalled Windows 2000 and I dont use IE so it's just the default installation.
Sorry if I caused you any headaches

 
- Tigerworks

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
12th January, 2005 at 12:52:50 -

lol, don't worry

 
191 / 9999 * 7 + 191 * 7

Long John Kickbag



Registered
  26/08/2002
Points
  148
12th January, 2005 at 17:20:27 -

Firefox 0.9.3 displays it right (has the right status bar text too). By the way, even with that filter IE doesn't display it quite right, it actually darkens the image slightly for some reason.

 
Resize! - www.clicksplat.com/comparison.html

醤油の兵士

Almost Human

Registered
  12/06/2002
Points
  173

VIP Member
12th January, 2005 at 19:39:31 -

eh, what's this about mac *looks at avatar*

You can tell opera to say it is a certain web browser, same with FF (if you get the plugin)

 
As a boy, I wanted to be a train. I didn’t realize this was unusual—that other kids played with trains, not as them.

Long John Kickbag



Registered
  26/08/2002
Points
  148
13th January, 2005 at 11:46:18 -

If you use this:

if(obj.style.filter.substring(0,50) == "progidXImageTransform.Microsoft.AlphaImageLoader")
{
obj.src = "blank.gif";
window.status = "IE is using PNG filter";
}

Then it should stop it messing up if the user makes there browser says it's a different browser, and if it's an older version of IE then it will still display a picture.

 
Resize! - www.clicksplat.com/comparison.html

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
13th January, 2005 at 12:36:48 -

But won't that cause errors for the browsers that don't have the 'filter' property?

 
n/a

Long John Kickbag



Registered
  26/08/2002
Points
  148
13th January, 2005 at 17:18:29 -

No, for graceful downgrading reasons (basically so people can make webpages in newer CSS versions without it not working on anything but the newest browsers), browsers automatically assign undefined properties to "".

(Accidently typed HTML instead of CSS.)

Image Edited by the Author.

 
Resize! - www.clicksplat.com/comparison.html

Long John Kickbag



Registered
  26/08/2002
Points
  148
15th January, 2005 at 19:47:07 -

Here's an automated way to allow alpha channels in IE 6 and still display an image in most other browers.

Make a blank image called blank.gif and put it in the same directory as your file (or remember to change it in the javascript).

Insert this somewhere in the body part of your file (browsers that don't support the filter style don't ignore it if you change it with javascript):
< img id="dxalphatest" style="width:0px;height:0px;filter:filtertest" /> (remove the space at the start)

(Note that this will actually invalidate your document (if you actually care) because filter isn't a real CSS property.)

Then put this after all your image definitions:

<script type="text/javascript">
if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 6.0") != -1 &&

document.getElementById("dxalphatest").style.filter)
if(document.getElementById("dxalphatest").style.filter == "filtertest")
{
for(var curimage = document.images.length-1; curimage > 0; curimage--)
document.images[curimage].style.filter =

"progidXImageTransform.Microsoft.AlphaImageLoader(src='"+document.images[curimage].src+"',sizingMethod='scale')";

for(var curimage = document.images.length-1; curimage > -1; curimage--)
document.images[curimage].src = "blank.gif";
}
</script>


That should work on a majority of browsers.

Image Edited by the Author.

 
Resize! - www.clicksplat.com/comparison.html

JP



Registered
  07/06/2003
Points
  1338
15th January, 2005 at 21:16:23 -

if the mac people are going to represent.... *hoists his colors*

 
Steve Zissou: Anne-Marie, do all the interns get Glocks?

Anne-Marie: No, they have to share one.

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
16th January, 2005 at 11:47:00 -

I've personally found defining this as a function works fine in all the browsers I've tested (Netscape, IE6, Firefox, Opera):

<script language="javascript">
 window.status = "Browser not using PNG filter";
 function png_check(obj){
    if(obj.style.filter.substring(0,50) == "progidXImageTransform.Microsoft.AlphaImageLoader")
     {
      obj.src = "blank.gif";
      window.status = "IE is using PNG filter";
     }
 }
</script>

Then just call it with the ID of my image.

Image Edited by the Author.

 
191 / 9999 * 7 + 191 * 7
   

Post Reply



 



Advertisement

Worth A Click