How to show browser doesn't supported error message ?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
premecorp
Forum Newbie
Posts: 15
Joined: Fri Nov 04, 2011 9:12 am

How to show browser doesn't supported error message ?

Post by premecorp »

I have used yahoo ping box, Its working fine on firefox and google crome but it not showing Internet Explorer. So in that case I want to show an error message "IE does not support in yahoo pingbox..." in that place. How can I do this thing if any one have any idea regarding this pls help me...

Regards,
Premashish
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: How to show browser doesn't supported error message ?

Post by Eric! »

You can detect IE in the html

Code: Select all

<!--[if IE]> <p>Ping Box is not supported by IE</p> <![endif]-->
or you could try in php using:

Code: Select all

$browser = get_browser(null, true);
//uncomment following line to see what's available
//print_r($browser); 
if(preg_match("/msie/i",$browser["browser"])) echo "IE sucks";
or find it via javascript with navigator object

Code: Select all

<html>
<body>
<div id="example"></div>
<script type="text/javascript">
txt = "<p>Browser CodeName: " + navigator.appCodeName + "</p>";
txt+= "<p>Browser Name: " + navigator.appName + "</p>";
txt+= "<p>Browser Version: " + navigator.appVersion + "</p>";
txt+= "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>";
txt+= "<p>Platform: " + navigator.platform + "</p>";
txt+= "<p>User-agent header: " + navigator.userAgent + "</p>";
document.getElementById("example").innerHTML=txt;
</script>
</body>
</html>
Post Reply