Solved

PNG for every browser EXCEPT MSIE

Posted on 2006-07-09
3
186 Views
Last Modified: 2008-03-17
Hello.

I have two versions of the image 'balloon.png'.

The .PNG looks better but it does not work properly on MSIE because it has an alpha-transparency.

So I want to serve the UGLY .GIF to MSIE users but the .PNG to everyone else.

Right now I use this to display the PNG version:
                    document.writeln("<img src='balloon.png' onmouseover='fix(\""+j+"\");'>");


I need something like this, but my syntax is off...

                    if (browser==MSIE) imgExt=".gif" else imgExt=".png"
                    document.writeln("<img src='balloon."+imgExt+"' onmouseover='fix(\""+j+"\");'>");


Any ideas  how?

Thanks!

0
Comment
Question by:hankknight
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
sam85281 earned 500 total points
ID: 17068944
if (navigator.appName == 'Microsoft Internet Explorer') {
// do this
} else {
//do this
}

-Sam
0
 
LVL 16

Expert Comment

by:sam85281
ID: 17068956
By the way, you CAN use a PNG in IE with a little simple scripting.

This tells all:

http://homepage.ntlworld.com/bobosola/

-Sam
0
 
LVL 16

Author Comment

by:hankknight
ID: 17069238
Thanks!

I accepted you first comment as the answer because it directly answers my question, but I will be using the IE PNG fix as a solution.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now