0

I have a website build using PHP and HTML. If a user browses my website using IE, I want to display a message saying: "Please use Firefox or Google Chrome" instead of rendering the index page.

Is it possible? If so how could it be done?

Please note I am not that advanced with PHP.

Thanks.

Salman A
  • 262,204
  • 82
  • 430
  • 521
Sarah Hamed
  • 119
  • 2
  • 4
  • 10
  • 1
    It's possible, but very likely unpreferable unless you're creating a banking website with users still having IE6. – Lekensteyn Apr 20 '12 at 11:34
  • 2
    @M42 - Guess Sarah likes to alienate users. – Ed Heal Apr 20 '12 at 11:36
  • 1
    you gave up on creating a css for IE? :) – mishu Apr 20 '12 at 11:37
  • 5
    IE is and will remain the best browser... for downloading another browser. – Salman A Apr 20 '12 at 11:55
  • Everyone in here knows what pain IE may become, in terms of **browser compatibility**; however, *this does NOT mean that it is acceptable* to **FORCE** your visitors use something else (simply because you just couldn't make it...) – Dr.Kameleon Apr 20 '12 at 12:01
  • @Dr.Kameleon, why not? IE is now down to 19%. People like Sarah could kick it on out the door. People are creatures of habit. She's giving them a reason to switch (using an app they need for work). Once they fuss for a day they'll never go back to IE. – toddmo Mar 26 '17 at 17:31

5 Answers5

2

You could also do it like this:

<?php 
function using_ie(){
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    $ub =false;
    if(preg_match('/MSIE/i',$user_agent))
    {$ub = true;}
    return $ub;
}


if(using_ie()==true){
    //Show notice
}else{
    //Cont
}

?>

Dont forget that that IE users still own 30% of the market share meaning 1 in 3.3 of your users will be using IE http://www.w3counter.com/globalstats.php

Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106
2

I will give you the best answer

include this code in <head>

<!--[if IE]>
<script>
  alert("Here you can write the warning box like this website is not supported by IE");
</script>
<script type="text/javascript">
window.location = "insert here the link of the webpage you want to redirect the users after clicking ok";
</script>
<![endif]-->
Adam IS
  • 51
  • 5
1

You can do that with Conditional Comments which are documented by the browser vendor (Microsoft).

With those you can make HTML accessible to IE users that are hidden in comments in every other standards compliant browser, like the message to download some other browser. You can even completely hide the rest of the page.

hakre
  • 193,403
  • 52
  • 435
  • 836
1

It is possible, but i just want to tell you it's really not a really good solution to a problem. The way it can be done is:

$browserinfo = get_browser();
$browser = $browserinfo['browser']

if ($browser == "Internet Explorer" || $browser == "InternetExplorer" || $browser == "IE") {
    include("path/to/your/errorMessage.php");
    exit(0);
}

This does require browscap. Another option is:

$u_agent = $_SERVER['HTTP_USER_AGENT']; 
$ub = false; 

if(preg_match('/MSIE/i',$u_agent)) 
{ 
    include("path/to/your/errorMessage.php");
    exit(0);
}
Manuel
  • 10,153
  • 5
  • 41
  • 60
0

Please checkout the user-agent as described here http://icfun.blogspot.de/2008/07/php-how-to-check-useragent.html

i hope this is what your are looking for ;-)

tingel2k
  • 392
  • 1
  • 12