Jump to content
xisto Community
Sign in to follow this  
Graeme

Javascript - What's Your Browser?

Recommended Posts

Here is the code that i picked up from a Javascript book that will tell you wether you are using Firefox or Internet explorer.

 

obviously the (navigator.appName =="browser name") can be changed to different browsers.

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 - Transitional//EN"><html xmlns="http://www.w3.org/1999/xhtml/;<head>		 <title>What's your browser?</title></head><body bgcolor="#FFFFFF"><h2>		   		<script language="Javascript1.5"		type="text/javascript">		<!-- Hide script from old browsers		if (navigator.appName =="Firefox") {		document.write("You are running a Firefox browser")		}		else {		if (navigator.appName == "Microsoft Internet Explorer") {		document.write("You are running Internet Explorer")		}		else {		document.write("You're not using Internet Explorer or Firefox, maybe you should!")		}	}		// End hiding script from old browsers -->		</script></h2></body></html>

Share this post


Link to post
Share on other sites

I have to concur especially since that most people disable javascript to begin with and doing it through php would be a lot cleaner and a lot smaller in the code size as well.

<?php echo $_SERVER["HTTP_USER_AGENT"]; ?>

That little one line of php cod and you just displayed the person's browser without making hte document look unorganized and large in document size

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.