PDA

View Full Version : How to show something diffrent for IE user?



WeeGiE
08-11-2008, 07:59 PM
Is there a way if a IE user comes on my website...I can make it display a completely diffrent page..from the users who use FireFox etc?

Jackboy
09-11-2008, 12:40 PM
Well i think an effective way to do it would be to use php.

Using conditional if statements you can create something along the lines of



<?
echo "
<!--[if IE]>";
include "internetexplorerfile.php";
die();
echo "
<![endif]-->

PAGE FOR OTHER BROWSERS SUCH AS FIREFOX HERE.
";


That would include that file then it would die so that the rest of the page isn't displayed.

If not then you could just use



<!--[if IE]>
<meta http-equiv="refresh" content="0.1; url=http://INTERNETEXPLORERLINK.com">
<![endif]-->


Both of them should work..

Iszak
09-11-2008, 12:55 PM
Erm, Jack your first example won't work because you're mixing HTML and PHP, PHP doesn't take into account the conditional comments, you'll have to make an if statement in PHP for it to work. E.g.



<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== false)
{
header("Location: http://www.domain.com");
}
?>


also you can use javascript


<script type="text/javascript">
if (navigator.appName === "Microsoft Internet Explorer")
{
window.location = "http://www.domain.com";
}
</script>


furthermore you can use the user agent.


<script type="text/javascript">
if (navigator.userAgent.search(/MSIE/) !== -1)
{
window.location = "http://www.domain.com";
}
</script>


As for the conditional comment as Jack posted


<!--[if IE]>
<meta http-equiv="refresh" content="1;url=http://www.domain.com">
<![endif]-->

This should do it if the browser supports the refresh like Jack posted, not sure if it has any drawbacks though. The other two you can have the browser user agent spoofed and people can simple disabled javascript so no solid way unless the conditional comment meta refresh works.

Jackboy
09-11-2008, 01:28 PM
Erm, Jack your first example won't work because you're mixing HTML and PHP, PHP doesn't take into account the conditional comments, you'll have to make an if statement in PHP for it to work. E.g.



<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== false)
{
header("Location: http://www.domain.com");
}
?>
also you can use javascript


<script type="text/javascript">
if (navigator.appName === "Microsoft Internet Explorer")
{
window.location = "http://www.domain.com";
}
</script>
furthermore you can use the user agent.


<script type="text/javascript">
if (navigator.userAgent.search(/MSIE/) !== -1)
{
window.location = "http://www.domain.com";
}
</script>
As for the conditional comment as Jack posted


<!--[if IE]>
<meta http-equiv="refresh" content="1;url=http://www.domain.com">
<![endif]-->
This should do it if the browser supports the refresh like Jack posted, not sure if it has any drawbacks though. The other two you can have the browser user agent spoofed and people can simple disabled javascript so no solid way unless the conditional comment meta refresh works.

You're right, i made a well nooby mistake :(

UniqueHabbo
10-11-2008, 06:59 PM
Iszak saves the day, once again.

Want to hide these adverts? Register an account for free!