admin管理员组

文章数量:1336311

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";</script><![endif]-->

This code working very good for IE 10:

 <script type="text/javascript">if (navigator.appName == 'Microsoft Internet Explorer'){self.location = "google"}</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?

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.";</script><![endif]-->

This code working very good for IE 10:

 <script type="text/javascript">if (navigator.appName == 'Microsoft Internet Explorer'){self.location = "google."}</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?

Share Improve this question edited Dec 17, 2020 at 2:51 Dmitry Shvedov 3,3064 gold badges40 silver badges56 bronze badges asked Jun 17, 2014 at 19:11 user3745530user3745530 151 silver badge3 bronze badges 7
  • 8 Out of curiosity, why do you need to redirect IE11 users? It's getting fairly standards-pliant (I'm not saying 100%). So I personally don't see why you would need to force a redirect for these users. – Jaime Garcia Commented Jun 17, 2014 at 19:13
  • ie 11 does identify as Ms internet explorer anymore.. see here stackoverflow./questions/17907445/how-to-detect-ie11 – G-Man Commented Jun 17, 2014 at 19:14
  • @ferrari fan .. activex maybe :) – G-Man Commented Jun 17, 2014 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 Commented Jun 17, 2014 at 19:21
  • 1 Try this: github./ded/bowser and use <script>if (bowser.msie) { ... }</script> pretty dependable in my experience. – vinczemarton Commented Jun 17, 2014 at 19:22
 |  Show 2 more ments

3 Answers 3

Reset to default 6

Following your ments, 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? */ }

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:

  • http://modernizr./
  • http://www.quirksmode/js/support.html

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

  • How to detect IE11?
  • how to detect IE11 using jquery
  • Jquery fail to detect IE 11

Ex:

if (!!navigator.userAgent.match(/Trident.*rv\:11\./)) {self.location = "google."}

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.

本文标签: javascriptHow to detect IE11 and redirect it to other siteStack Overflow