JS Detects Browser, Then Replaces Images/Code/CSS

A

Amanda H.

Hi guys,

I just started switching my site over to tableless css, and I'm using a
very lovely, transparent PNG-24 image. I have been trying to figure
out if there is any way to replace an image before loading only for
certain browsers using either javascript or PHP (I'm using PHP to
switch stylesheets and prefer server-side).

The problem is IE's handling of PNG-24 files: every other browser has
alpha compatibility and displays PNG-24 images correctly, even IE/Mac.
But IE/Win shows the transparent areas as blue. This is a commonly
known bug that I haven't been able to find a definitive fix for.

What I want to happen is for the JS or PHP to detect if the browser is
IE/Win. Then, if so, replace the code or load an alternate css
stylesheet to display a GIF instead of the PNG. I am mostly using the
PNG-24 in a div as a background-image in an external stylesheet.

Anyone had any idea if this is possible? I only have a meager
understanding of javascript and PHP, so any help would be greatly
appreciated.

Thanks,

Amanda H.
 
L

Luke Matuszewski

Amanda H. napisal(a):
The problem is IE's handling of PNG-24 files: every other browser has
alpha compatibility and displays PNG-24 images correctly, even IE/Mac.
But IE/Win shows the transparent areas as blue. This is a commonly
known bug that I haven't been able to find a definitive fix for.

Yet there are some common working workarounds. See:

<URL:http://dean.edwards.name/IE7/>

or simply:

<URL:http://koivi.com/ie-png-transparency/>

(the solution from http://homepage.ntlworld.com/bobosola/ is not very
elegant).

B.R.
Luke Matuszewski
 
L

Luke Matuszewski

Amanda H. napisal(a):
The problem is IE's handling of PNG-24 files: every other browser has
alpha compatibility and displays PNG-24 images correctly, even IE/Mac.
But IE/Win shows the transparent areas as blue. This is a commonly
known bug that I haven't been able to find a definitive fix for.

Yet there are some common working workarounds. See:

<URL:http://dean.edwards.name/IE7/>

or simply:

<URL:http://koivi.com/ie-png-transparency/>

(the solution from http://homepage.ntlworld.com/bobosola/ is not very
elegant).

B.R.
Luke Matuszewski
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top