check for IE and display another page
I have a web app which is currently not rendering in IE. For the time being, I 开发者_如何学JAVAwant to check for IE and display another page for IE visitors. How can I do it? Do I need javascript or PHP?
Besides the $_SERVER['HTTP_USER_AGENT']
you could use IE's conditional comments, combined with a meta tag or javascript like below:
<!--[if IE]>
<meta http-equiv="refresh" content="0;URL=/IEonly.php" />
<![endif]-->
This is a PHP function, i prefer PHP for this because ideally you shall know the browser at the server side rather than client side in your case.
function detect_ie()
{
if (isset($_SERVER['HTTP_USER_AGENT']) &&
(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
return true;
else
return false;
}
This snippet will return true of the browser is IE, in this snippet the browser version is not being checked as it isnt required by your question
hope this helps
PHP can do it. Check $_SERVER['HTTP_USER_AGENT']
.
JavaScript can do it as well. You have the navigator object, which has a bunch of properties identifying the browser:
- appName: The name of the browser.
- appVersion: The version of the browser.
Depending on what browser you have, you can do a redirect to another page then.
精彩评论