• 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

    • This is listed as a preview in WU for me. I usually don't grab them as previews; what's your opinion on it so far?
    • Pale Moon 34.3.1 by Razvan Serea Pale Moon is an Open Source, Goanna-based web browser available for Microsoft Windows, Linux and Android, focusing on efficiency and ease of use. Make sure to get the most out of your browser! Pale Moon offers you a browsing experience in a browser completely built from its own, independently developed source that has been forked off from Firefox/Mozilla code, with carefully selected features and optimizations to improve the browsers speed, resource use, stability and user experience, while offering full customization and a growing collection of extensions and themes to make the browser truly your own. Features: Optimized for modern processors Based on proprietary optimized layout engine (Goanna) Safe: forked from mature Mozilla code and regularly updated Secure: Additional security features and security-aware development Supported by our user community, and fully non-profit Familiar, efficient, fully customizable interface Support for full themes: total freedom over any elements design Support for easily-created lightweight themes (skins) Smooth and speedy page drawing and script processing Increased stability: experience fewer browser crashes Support for many Firefox extensions Support for a growing number of Pale Moon exclusive extensions Extensive and growing support for HTML5 and CSS3 Many customization and configuration options Pale Moon 34.3.1 changelog: Pale Moon will now exclude local resources from CSP checks, aligning it with the rest of CSP handling. Fixed an issue where the devtools JSON viewer would, in some cases, make erroneous requests to remote servers. Updated libpng to 1.6.58+apng. Updated NSS to 3.90.12 (UXP), addressing multiple security issues. Fixed several intermittent and rare crashes. Security issues addressed: CVE-2026-12318 (CWE-125), CVE-2026-12322, CVE-2026-12292 (DiD), and multiple other issues that did not have a CVE designation at the time of patching. Download: Pale Moon (64-bit) | Portable 64-bit | ~40.0 MB (Freeware) Download: Pale Moon (32-bit) | Portable 32-bit Links: Pale Moon Homepage | Add-ons | Themes | Extensions | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Onwards to Windows 12 then lol.
  • Recent Achievements

    • 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
    • One Month Later
      D0nn13 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      425
    2. 2
      +Edouard
      177
    3. 3
      PsYcHoKiLLa
      124
    4. 4
      Michael Scrip
      77
    5. 5
      Xenon
      76
  • Tell a friend

    Love Neowin? Tell a friend!