Jump to content

Recommended Posts

If a user is using internet explorer, display error "You are not using a browser that is supported. Please reload in Google Chrome or Mozilla Firefox to access content", otherwise display page.

 

Not sure if this is possible with an if else statement, or even php for that matter. Does anyone know what I'm talking about, and if so, any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/228455-not-sure-how-to-explain-this/
Share on other sites

If a user is using internet explorer, display error "You are not using a browser that is supported. Please reload in Google Chrome or Mozilla Firefox to access content", otherwise display page.

 

Not sure if this is possible with an if else statement, or even php for that matter. Does anyone know what I'm talking about, and if so, any suggestions?

 

I do:

 

$using_ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE);

    if ($using_ie)
    {
        die("We hate your browser (Internet Explorer), and therefore you don't deserve to use our site.<br /><a href='http://www.google.com/chrome/intl/en/landing_chrome.html?hl=en'>Get Chrome</a>");
    }

 

I think it has some flaws though since some browsers have MSIE in the tag, older versions of Opera I think..

 

Overall I advise against this anyway, I just do it in spite of IE for the time being till I fix my problems with it.

 

If it's styling that's the issue, look into conditional stylesheets. (Meaning, use one stylesheet for IE, and another for other browsers).

If a user is using internet explorer, display error "You are not using a browser that is supported. Please reload in Google Chrome or Mozilla Firefox to access content", otherwise display page.

 

Not sure if this is possible with an if else statement, or even php for that matter. Does anyone know what I'm talking about, and if so, any suggestions?

 

I do:

 

$using_ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE);

    if ($using_ie)
    {
        die("We hate your browser (Internet Explorer), and therefore you don't deserve to use our site.<br /><a href='http://www.google.com/chrome/intl/en/landing_chrome.html?hl=en'>Get Chrome</a>");
    }

 

I think it has some flaws though since some browsers have MSIE in the tag, older versions of Opera I think..

 

Overall I advise against this anyway, I just do it in spite of IE for the time being till I fix my problems with it.

 

If it's styling that's the issue, look into conditional stylesheets. (Meaning, use one stylesheet for IE, and another for other browsers).

 

See, I tried that because I'm using the new CSS3 animations and box shadows, etc. and it's too complicated for me to add multibrowser support for each one, so I decided to just go with this method.

 

I have a couple questions about your code...

 

1. Do I wrap the entire document (including the !doctype tag) inside the <php> tags?

 

2. What do you mean some browsers have MSIE in the tag?

as Zurev suggested, you probably shouldn't completely remove IE from the access list.. You really need to set up a style sheet for IE. Obviously without the coolness of CSS3. You can just display a message to the user that you know they're using IE and they won't get the full experience of your website unless they switch to a (better) browser like Chrome or Firefox..

 

Denno

If you so must...

<?php

$using_ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE);

    if ($using_ie)
    {
        die("We hate your browser (Internet Explorer), and therefore you don't deserve to use our site.<br /><a href='http://www.google.com/chrome/intl/en/landing_chrome.html?hl=en'>Get Chrome</a>");
    }

// any other php code you have could go here... 

?> 

doctype
html
body
etc

If you so must...

<?php

$using_ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE);

    if ($using_ie)
    {
        die("We hate your browser (Internet Explorer), and therefore you don't deserve to use our site.<br /><a href='http://www.google.com/chrome/intl/en/landing_chrome.html?hl=en'>Get Chrome</a>");
    }

// any other php code you have could go here... 

?> 

doctype
html
body
etc

 

I put that code right after the <body> tag, because it was conflicting with other php code I have before the <!doctype> tag.

 

I have another question, though.

 

What are the other browser names?

For example,

$using_ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== FALSE);

for Mozilla Firefox.

 

Is there a list online somewhere with all of the browser's names on it, specific to this kind of code?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.