Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Why does IE put a gray background on my image?

Reply
Thread Tools

Why does IE put a gray background on my image?

 
 
John Salerno
Guest
Posts: n/a
 
      02-05-2006
Here is my first JavaScript experiment (naturally a rollover!). But my
question is about the image itself. It looks fine in Firefox and Opera,
but in IE it has a gray background. The image itself has a transparent
background, so I have no idea where the gray comes from.

http://www.johnjsal.com/button.html
 
Reply With Quote
 
 
 
 
Roy Schestowitz
Guest
Posts: n/a
 
      02-05-2006
__/ [John Salerno] on Sunday 05 February 2006 08:19 \__

> Here is my first JavaScript experiment (naturally a rollover!). But my
> question is about the image itself. It looks fine in Firefox and Opera,
> but in IE it has a gray background. The image itself has a transparent
> background, so I have no idea where the gray comes from.
>
> http://www.johnjsal.com/button.html


Internet explorer does not handle high bit-level (32 bits?) transparencies.
This affects alpha blending rather badly. The solution is often to embed the
object in background with the same colour as that which IE renders the
transparency part. The other solution is to persuade everybody to upgrade to
good Web browser, thereby allowing the IE deficiency take it toll rather
than be worked around. The issue should have been addressed in the
development of IE7.

Roy

--
Roy S. Schestowitz | "All your archives are (sic) belong to Google"
http://Schestowitz.com | SuSE Linux | PGP-Key: 0x74572E8E
9:10am up 19 days 4:26, 14 users, load average: 1.16, 1.06, 0.96
http://iuron.com - next generation of search paradigms
 
Reply With Quote
 
 
 
 
Neredbojias
Guest
Posts: n/a
 
      02-05-2006
With neither quill nor qualm, John Salerno quothed:

> Here is my first JavaScript experiment (naturally a rollover!). But my
> question is about the image itself. It looks fine in Firefox and Opera,
> but in IE it has a gray background. The image itself has a transparent
> background, so I have no idea where the gray comes from.
>
> http://www.johnjsal.com/button.html


It's because it's a png. IE doesn't do png transparencies well. Try a
gif.

--
Neredbojias
Contrary to popular belief, it is believable.
 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      02-05-2006
Neredbojias wrote:

> It's because it's a png. IE doesn't do png transparencies well. Try a
> gif.


And with a little creativity, you could serve up a transparent GIF to any
browsers with "MSIE" in their user-agent string, and a PNG to everyone
else.

Alternatively, there are a few tricks to get IE to handle alpha-blended
PNGs. They don't make for pretty coding, but can give you pretty pages.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
Alan J. Flavell
Guest
Posts: n/a
 
      02-05-2006
On Sun, 5 Feb 2006, Toby Inkster wrote:

> And with a little creativity, you could serve up a transparent GIF
> to any browsers with "MSIE" in their user-agent string, and a PNG to
> everyone else.


Don't do that - it's bad in principle, and works badly in practice.
For all the usual reasons.

PNG versus GIF can be successfully negotiated on the basis of the
client's initial Accept: header. As far as I recall, even MSIE gets
this correct enough to be useful - at least on its initial request.

Apache's MultiViews will do this pretty much for free, out of the box,
if you let it.

(MSIE has a silly habit of sending "Accept: */*" when reload is used,
but I guess we can live with that. Workarounds would likely have
negative impact on real WWW browsers, so I won't suggest those. But
your proposed kludge would have negative impact on /all/ of the real
WWW minority browsers that feel they need to masquerade as MSIE in
order not to get locked out by idiot webmasters.)
 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      02-05-2006
Alan J. Flavell wrote:
> Toby Inkster wrote:
>
>> And with a little creativity, you could serve up a transparent GIF
>> to any browsers with "MSIE" in their user-agent string, and a PNG to
>> everyone else.

>
> Don't do that - it's bad in principle, and works badly in practice.
> For all the usual reasons.


Pah! I'll agree that detecting browser by user-agent string is generally
rather hit-and-miss, but this is one particular application where
user-agent matching won't cause any problems.

Potential pitfall #1: a non-IE browser has "MSIE" in the user-agent string
and gets sent a GIF instead of a PNG. This isn't a huge problem -- the
only browser that does this by default is Opera, but this will change in
version 9.0. And when a browser does do this, it gets the GIF, which
should still look fairly good -- just not as good as the PNG.

Potential pitfall #2: vice-versa. It is possible, but difficult to change
the u-a string for MSIE. But because it's quite tricky, not many people
will have done it, so not really worth worrying about. Besides which, the
only problem they'll experience in this case will be cosmetic.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
Alan J. Flavell
Guest
Posts: n/a
 
      02-05-2006

On Sun, 5 Feb 2006, Toby Inkster wrote:

> Potential pitfall #1: a non-IE browser has "MSIE" in the user-agent string

[...]

You've only bothered with the *obvious* pitfalls. As you say, those
are basically cosmetic, in relation to the present problem.

Then there's cacheability, particularly in relation to those who
(knowingly or unknowingly) are accessing web resources via a proxy
cache server.

Using proper content-negotiation techniques such as MultiViews would
at least behave protocol-correctly in that regard. You may not think
the practical consequences are ideal - but it's the best we've got,
whenever you have a requirement to send different content to different
clients. And at least if *you* play your part in that concordat, the
other participants always have a chance to improve the part which
falls to /them/

Whereas, if you kludge your part, none of the other participants gets
the chance to do better.
 
Reply With Quote
 
Neredbojias
Guest
Posts: n/a
 
      02-05-2006
With neither quill nor qualm, Toby Inkster quothed:

> Neredbojias wrote:
>
> > It's because it's a png. IE doesn't do png transparencies well. Try a
> > gif.

>
> And with a little creativity, you could serve up a transparent GIF to any
> browsers with "MSIE" in their user-agent string, and a PNG to everyone
> else.
>
> Alternatively, there are a few tricks to get IE to handle alpha-blended
> PNGs. They don't make for pretty coding, but can give you pretty pages.


Quite true, although I think AJF has a bit of a point. Anyway, alpha
pings confuse me so I prefer the simplicity of a gif (with, sadly, its
256 color limit) when dealing with web transparencies.

--
Neredbojias
Contrary to popular belief, it is believable.
 
Reply With Quote
 
kchayka
Guest
Posts: n/a
 
      02-06-2006
Neredbojias wrote:
>
> alpha
> pings confuse me so I prefer the simplicity of a gif (with, sadly, its
> 256 color limit) when dealing with web transparencies.


So, use 256-color png instead. IE handles them the same as gif, plus the
resulting image size will be smaller than a 24- or 32-bit png.

In the OP's case, alpha transparency isn't really needed, anyway.
Indexed transparency is plenty adequate.

--
Reply email address is a bottomless spam bucket.
Please reply to the group so everyone can share.
 
Reply With Quote
 
Neredbojias
Guest
Posts: n/a
 
      02-07-2006
With neither quill nor qualm, kchayka quothed:

> Neredbojias wrote:
> >
> > alpha
> > pings confuse me so I prefer the simplicity of a gif (with, sadly, its
> > 256 color limit) when dealing with web transparencies.

>
> So, use 256-color png instead. IE handles them the same as gif, plus the
> resulting image size will be smaller than a 24- or 32-bit png.


Oh really? I didn't know that (although I _have_ found that pings are
usually smaller than gifs when the number of colors is the same.) I'll
try it the next time I need simple transparency.
>
> In the OP's case, alpha transparency isn't really needed, anyway.
> Indexed transparency is plenty adequate.
>
>


--
Neredbojias
Contrary to popular belief, it is believable.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why does the following with Queue, q.put('\x02', True) not put itin the queue? Gabriel Rossetti Python 3 04-25-2008 03:41 PM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
why is the default color of JComboBox gray instead of white? - Java 9 03-25-2005 11:33 AM
Resizing a transparent image adds gray background Oleg Ogurok ASP .Net 0 01-27-2005 05:18 AM



Advertisments