2014-10-07 2 views
0

나는 그것은 같은 크롬 등 다른 브라우저도 error.html 페이지로 리디렉션되는 떨어져 사실에서 치료처럼 작동 다음 스크립트Internet Explorer 사용자를 새 페이지로 리디렉션하는 방법은 무엇입니까?

[if IE] 
<script type="text/javascript"> 
window.location = "error.html"; 
</script> 
[endif] 

를 사용하여 시도했다. 그게 뭐가 잘못 되었 니? 감사합니다

+0

http://msdn.microsoft.com/en-us/library/ms537512(v=vs. 85) .aspx – j08691

+2

하지 마십시오. 진지하게. 사람들이 IE, 특히 현대 IE를 사용하고 싶다면. 그들을 시키십시오. 기능 감지 및 점진적 향상 기능을 대신 사용하십시오. – Quentin

답변

2

을이 시도 : 내 생각에 내가 여기에 모든 주위에 답이 있었다 알고 있지만, 비엔나

에서
+1

IE 11과 일치하지 않습니다. http://blogs.msdn.com/b/ieinternals/archive/2013/09/21/internet-explorer-11-user-agent-string -a-string-sniffing-compatibility-with-gecko-webkit.aspx – Quentin

+0

게시물을 편집했습니다 ... :) – Bernd

+0

이제 Chrome이 IE11이라고 생각합니다. – Quentin

0

조건부 주석을 사용해야합니다.

IE10 +는 이러한 조건부 주석을 존중하지 않으며 Firefox 및 Chrome과 동일한 방식으로 처리합니다.

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

이 시도 :

if (window.navigator.userAgent.indexOf("MSIE ") > 0) 
    window.location="error.html"; 
+0

IE 11과 일치하지 않습니다. http://blogs.msdn.com/b/ieinternals/archive/2013/09/21/internet-explorer-11-user-agent-string-ua-string-sniffing-compatibility -with-gecko-webkit.aspx – Quentin

2

<script type="text/javascript"> 
if(navigator.appName.indexOf("Internet Explorer")!=-1 || navigator.userAgent.match(/Trident.*rv[ :]*11\./)) 
{ 
    //This user uses Internet Explorer 
    window.location = "error.html"; 
} 
</script> 

인사말을 가장 완전한 대답은 ..

HTML

<p>Is this internet explorer?<p> 
<p id="ie"></p> 

이제 자바 스크립트

if(detectIE()){ 
    document.getElementById("ie").innerHTML = "Yes it is!"; 
} else { 
    document.getElementById("ie").innerHTML = "No it's not!"; 
} 

function detectIE() { 
    var ua = window.navigator.userAgent; 

    var msie = ua.indexOf('MSIE '); 
    if (msie > 0) { 
    return true; 
    } 

    var trident = ua.indexOf('Trident/'); 
    if (trident > 0) { 
    return true; 
    } 

    var edge = ua.indexOf('Edge/'); 
    if (edge > 0) { 
    return true; 
    } 

    // other browser 
    return false; 
} 

근무 예 : https://codepen.io/gerritman123/pen/VjrONQ

관련 문제