Thursday, September 22, 2011

Javascript change picture for different browser.?

I want to display a different image on my website based on the user's web browser. I have found a site that will accurately tell me which browser I am using, so I know that it's possible. http://whatbrowseramiusing.com/ I copied the source code form that site to my site and it worked but I couldn't figure out how to display an image instead of text. There is a line;

identity: ';Firefox';

used several times in there that I have figured out, if I change the text there the text displayed on the page will change. But like I said, I haven't figured out how to switch that text out for a picture.

To make things more complicated I want to image to change on mouse over. But I figured out how to do that from; http://www.angelfire.com/nm/thehtmlsourc . If you can include anything different that I have to do here in your answer I would appreciate it. (I'm not very good with javascript, so if you can give complete code and explain your answer a little bit I would appreciate it. )

P.S. I have figured out how to redirect the user to a completely different page based on their browser but I don't want to do that, I just want the image pair (mouse over and mouse not over) to change based on the user's browser.Javascript change picture for different browser.?
if( navigator.appName == ';Microsoft Internet Explorer'; ){

// DO FOR IE

}

else

{

// DO FOR OTHERS

}

No comments:

Post a Comment