0

I must redirect IE user to other website and from IE6 to IE9 this code working very good:

 <!--[if IE]><script type="text/javascript">window.location = "google.com";</script><![endif]-->

This code working very good for IE 10:

 <script type="text/javascript">if (navigator.appName == 'Microsoft Internet Explorer'){self.location = "google.com"}</script>

But I can't find any solution for IE11 - in this browser my website doesn't redirect.

Maybe you know how to write only one script to redirect all IE browsers to other website?

Dmitry Shvedov
  • 3,169
  • 4
  • 39
  • 51
user3745530
  • 15
  • 1
  • 3
  • 8
    Out of curiosity, why do you need to redirect IE11 users? It's getting fairly standards-compliant (I'm not saying 100%). So I personally don't see why you would need to force a redirect for these users. – Jaime Garcia Jun 17 '14 at 19:13
  • ie 11 does identify as Ms internet explorer anymore.. see here http://stackoverflow.com/questions/17907445/how-to-detect-ie11 – G-Man Jun 17 '14 at 19:14
  • @ferrari fan .. activex maybe :) – G-Man Jun 17 '14 at 19:15
  • I know but i make a preloader only for VP9 videos in html5 and i clean more code to have good optimization. :) i can't preload h264 files, and all users IE and Safari redirect to h264 special folder and have a nice fun dear users IE. ;-) I remember have got a problems with optymalization in h264 in Firefox browser i use standard vp8 + add source h264 .mp4 but FF always use .mp4 and sometimes video it's lag and blocking ;) – user3745530 Jun 17 '14 at 19:21
  • 1
    Try this: https://github.com/ded/bowser and use `` pretty dependable in my experience. – vinczemarton Jun 17 '14 at 19:22
  • Hm, interesting. I can't claim to have done anywhere near as much video-optimization testing as you, but my basic experience was that all browsers support H264 now, and that preloading isn't dependent on codec. – Katana314 Jun 17 '14 at 19:23
  • Can't you do feature detection with modernizr instead? And check for video format support? – vinczemarton Jun 17 '14 at 19:24

3 Answers3

6

Following your comments, browser-detection is NOT the way to go.

Instead, use feature detection. In this case:

var test = document.createElement('video');
if( !test.canPlayType) { /* HTML5 video not supported at all */ }
else if( !test.canPlayType("video/whatever")) {
    // replace "whatever" with the correct MIME type
    // if that type is not supported, do something here
}
else { /* you're all good? */ }
Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
2

Please Don't Do This.

Browser detection is known to be very unreliable and is not future proof at all.
As evidenced by you having this problem in the first place.

Instead, detect browser features and deliver what you need to based off those.

Check out these resources:


If you have to do this, then you can use any of these methods:

Ex:

if (!!navigator.userAgent.match(/Trident.*rv\:11\./)) {self.location = "google.com"}
Community
  • 1
  • 1
KyleMit
  • 30,350
  • 66
  • 462
  • 664
  • Feature detection is a great ideal, but given some of my own work with cutting-edge video-related technologies, it's just not viable for absolutely everything yet. If user experience is critical, then a developer DOES need to program things like "Is this Chrome, the ONLY browser that behaves a little bit differently with this particular feature it THINKS it supports?" One of the OP's comments illustrates the HTML5 Video troubles he's having, in spite of all browsers supporting all codecs. – Katana314 Jun 17 '14 at 19:43
0

Gonna echo Ferrari fan's sentiments...Many of the old reasons you'd put IE users on a different site are no longer really valid.

Anyway, in my experience, with IE11's recent changes, a more reliable method of browser sniffing is by checking the "Trident" version in navigator.userAgent, rather than the IE version. Mine is:

Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR
3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; rv:11.0) like Gecko

Here it's listed as 7.0, which premiered with IE11. 6 or lower would be other versions. Keep in mind that IE's release cycle may get faster like other browsers, so it's feasible your site would be handling "Trident/10.0" (IE 14) before long - make sure your pattern matching accounts for that.

OJFord
  • 10,522
  • 8
  • 64
  • 98
Katana314
  • 8,429
  • 2
  • 28
  • 36