You are here: Re: PHP Detects Browser, Then Replaces Images/Code/CSS « PHP Programming Language « IT news, forums, messages
Re: PHP Detects Browser, Then Replaces Images/Code/CSS

Posted by Carl on 02/11/06 03:45

Amanda H. wrote:
> 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.
>

In php you can check the value of $_SERVER['HTTP_USER_AGENT'] or the
return value of the get_browser() function (
http://www.php.net/function.get-browser ), and echo the statement that
imports the stylesheet accordingly.

Alternatively, have you considered using the 'underscore hack' (
http://www.google.com/search?q=css+underscore+hack ) in your css file to
change the background-image value when the css is loaded in IE?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация