• 0

re-direct if IE detected


Question

14 answers to this question

Recommended Posts

  • 0

I've heard that it's not always reliable to check the user's browser from PHP, but I admit I haven't researched it much. You're probably fine doing it this way since the cases where it doesn't work is likely someone doing something they shouldn't be doing.

  • 0
I've heard that it's not always reliable to check the user's browser from PHP, but I admit I haven't researched it much. You're probably fine doing it this way since the cases where it doesn't work is likely someone doing something they shouldn't be doing.

It's actually very unreliable. In fact, there's not a single way you could discriminate between different browsers by relying solely on some variable supplied by a browser, because they could all be changed with relative ease. The only sure way is to put a hack together that exploits the varying degree of technological sophistication amongst the different rendering engines, and make them filter themselves (if the browser doesn't support a certain technology, editing the UA won't change a damn thing). Suffice it to say, not very pretty and often not possible anyways. Only under very limited circumstances could you effectively tell what browser is what, so there's basically no point in trying to discriminate amongst them. The effort would be much better spent making the website just work with every browser.

  • 0

bad idea, just make it work in every browser :)

but if you really want to do this there is a better way

<!--[if lte IE 6]>

<script type="text/javascript">

window.location = "blabla";

</script>

<![endif]-->

will let you redirect ie6. I don't see any reason to redirect ie7 because a lot of the hacks aren't necessary anymore and making a site work in ff, opera and ie7 isn't really that difficult

  • 0
bad idea, just make it work in every browser :)

but if you really want to do this there is a better way

<!--[if lte IE 6]>

<script type="text/javascript">

window.location = "blabla";

</script>

<![endif]-->

will let you redirect ie6. I don't see any reason to redirect ie7 because a lot of the hacks aren't necessary anymore and making a site work in ff, opera and ie7 isn't really that difficult

IE7 has some rather....shall we say, interesting, rendering bugs that I don't believe occured in IE6.

In any case, why not just use if lt IE7? (1 less character!), and the javascript redirect won't work for everyone. Same problem with meta redirects as well.

  • 0
In fact, there's not a single way you could discriminate between different browsers by relying solely on some variable supplied by a browser, because they could all be changed with relative ease...

Only under very limited circumstances could you effectively tell what browser is what, so there's basically no point in trying to discriminate amongst them. The effort would be much better spent making the website just work with every browser.

Until Microsoft get their act together and properly deal with the XHTML1.1 content type (and by which time you shouldn't / won't want to redirect) you can check $_SERVER['HTTP_ACCEPT'] / Request.ServerVariables("HTTP_ACCEPT") for "application/xhtml+xml". Opera says it can handle it, as does the fox, Safari does the IE trick of allegedly supporting everything ("*/*"), unless that's changed recently. Whilst UA is easy peasy (even for IE) to change, the Accept shouldn't be able to be altered.

  • 0
Until Microsoft get their act together and properly deal with the XHTML1.1 content type (and by which time you shouldn't / won't want to redirect) you can check $_SERVER['HTTP_ACCEPT'] / Request.ServerVariables("HTTP_ACCEPT") for "application/xhtml+xml". Opera says it can handle it, as does the fox, Safari does the IE trick of allegedly supporting everything ("*/*"), unless that's changed recently. Whilst UA is easy peasy (even for IE) to change, the Accept shouldn't be able to be altered.

it's possible, why anyone would ever want to change it is beyond me. but as you said, using http_accept will give you problems with safari (which is more correct than IE in claiming */*).

  • 0

I used to check to see if it contained "MSIE", but didn't contain Opera (because Opera used to identify as IE)

And don't check for Safari, check for WebKit, otherwise you'll break other mac browsers (and some are really fun, they use WebKit but override XHTML rendering and treat it as RSS!)

:sleep:

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Still hate Windows 11, I stuck it on my gaming machine again just for a nose to see what they had done, still as bad. Will restore Windows 10 back on it, suit MS anyway, they don't want me to run Windows 11 on it.
    • Ms did go with the you must sign into an account thing with Windows 8 for a while. The same sort of thing they are doing with Windows now and the MS account.
    • Hello, What sort of Microsoft Authenticator account login approval requests are you getting?  It is a generic authentication app and can be used with all sorts of services (Microsoft Account, Google Account, websites and services that support multi-factor authentication, etc.). Regards, Aryeh Goretsky
    • Windows 8? Nah. I found Window 8 worked well, get a third party start menu to get rid of the start screen, I used Start is back and windows 8 was pretty good. I used it even when Windows 10 came out as I found Windows 10 was iffy on my machine at the time was AMD FX Bulldozer based. It was only when I updated the innards to Ryzen that I had no choice but to go to Windows 10 as MS made it difficult to stay with Windows 8. ME, yes, that was not great, I liked the look of it, but it was not stable, shame really because Windows 98SE was the best of the dos based Windows.
  • Recent Achievements

    • Rookie
      krychek57 went up a rank
      Rookie
    • Grand Master
      Jaybonaut went up a rank
      Grand Master
    • One Year In
      Philsl earned a badge
      One Year In
    • Dedicated
      Scoobystu earned a badge
      Dedicated
    • First Post
      Tom Schmidt earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      441
    2. 2
      +Edouard
      172
    3. 3
      PsYcHoKiLLa
      134
    4. 4
      Michael Scrip
      79
    5. 5
      Xenon
      77
  • Tell a friend

    Love Neowin? Tell a friend!