사용자가 IE를 사용하고 있는지 확인합니다.
특정 클래스의 div를 클릭하여 아래와 같은 함수를 호출합니다.
사용자가 Internet Explorer를 사용하는 경우 기능을 시작할 때 확인하고 다른 브라우저를 사용하는 경우 IE 사용자만 실행할 수 있도록 중단/취소할 수 있는 방법이 있습니까?이 사용자는 모두 IE8 이상 버전이기 때문에 IE7 이하 버전에서는 다루지 않아도 됩니다.
어떤 브라우저를 사용하고 있는지 알 수 있으면 좋겠지만 필수는 아닙니다.
함수 예:
$('.myClass').on('click', function(event)
{
// my function
});
몇 년이 지난 지금 Edge 브라우저는 렌더링 엔진으로 Chromium을 사용하고 있습니다.
안타깝게도 IE 11을 확인하는 것은 여전히 중요합니다.
IE의 오래된 버전은 사라져야 하므로 보다 간단한 접근법이 있습니다.
if (window.document.documentMode) {
// Do IE stuff
}
다음은 이전 답변(2014년)입니다.
Edge에서 사용자 에이전트 문자열이 변경되었습니다.
/**
* detect IEEdge
* returns version of IE/Edge or false, if browser is not a Microsoft browser
*/
function detectIEEdge() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
// IE 10 or older => return version number
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
}
var trident = ua.indexOf('Trident/');
if (trident > 0) {
// IE 11 => return version number
var rv = ua.indexOf('rv:');
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
}
var edge = ua.indexOf('Edge/');
if (edge > 0) {
// Edge => return version number
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
}
// other browser
return false;
}
사용 예:
alert('IEEdge ' + detectIEEdge());
IE 10의 기본 문자열:
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)
IE 11의 기본 문자열:
Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko
Edge 12의 기본 문자열:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0
Edge 13 기본 문자열(thx @DrCord):
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586
Edge 14의 기본 문자열:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/14.14300
Edge 15의 기본 문자열:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063
Edge 16 기본 문자열:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299
Edge 17의 기본 문자열:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134
Edge 18 기본 문자열(내부 미리 보기):
Mozilla/5.0 (Windows NT 10.0; Win64; x64; ServiceUI 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17730
CodePen에서의 테스트:
http://codepen.io/gapcode/pen/vEJNZN
다음 JavaScript 메서드 사용:
function msieversion()
{
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0) // If Internet Explorer, return version number
{
alert(parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))));
}
else // If another browser, return 0
{
alert('otherbrowser');
}
return false;
}
상세한 것에 대하여는, 다음의 Microsoft 서포트 사이트를 참조해 주세요.
업데이트 : (IE 11 지원)
function msieversion() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer, return version number
{
alert(parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))));
}
else // If another browser, return 0
{
alert('otherbrowser');
}
return false;
}
브라우저가 IE인지 아닌지만 알고 싶다면 다음을 수행할 수 있습니다.
var isIE = false;
var ua = window.navigator.userAgent;
var old_ie = ua.indexOf('MSIE ');
var new_ie = ua.indexOf('Trident/');
if ((old_ie > -1) || (new_ie > -1)) {
isIE = true;
}
if ( isIE ) {
//IE specific code goes here
}
업데이트 1: 더 나은 방법
지금 추천할게요.아직 읽기 쉽고 코드도 훨씬 적습니다:)
var ua = window.navigator.userAgent;
var isIE = /MSIE|Trident/.test(ua);
if ( isIE ) {
//IE specific code goes here
}
Johnny Fun 님의 짧은 답변 코멘트 덕분입니다.
업데이트 2: CSS에서의 IE 테스트
수 있으면 요.@supports
브라우저가 특정 CSS 기능을 지원하는지 여부를 확인하기 위해 JS 대신 문을 사용합니다.
.element {
/* styles for all browsers */
}
@supports (display: grid) {
.element {
/* styles for browsers that support display: grid */
}
}
하지 않습니다).@supports
스타일도 무시합니다.@supports
를 참조해 주세요.
경우@supports
을 사용하다
// JS
var ua = window.navigator.userAgent;
var isIE = /MSIE|Trident/.test(ua);
if ( isIE ) {
document.documentElement.classList.add('ie')
}
/* CSS */
.element {
/* styles that apply everywhere */
}
.ie .element {
/* styles that only apply in IE */
}
(주:classList
JS는 비교적 새로운 버전이고 IE 브라우저 중 IE11에서만 동작한다고 생각합니다.IE10 ))))))))) )
프로젝트에서 SCSS(Sass)를 사용하고 있는 경우는, 다음과 같이 간단하게 할 수 있습니다.
/* SCSS (Sass) */
.element {
/* styles that apply everywhere */
.ie & {
/* styles that only apply in IE */
}
}
업데이트 3: Microsoft Edge 추가(권장하지 않음)
마이크로소프트 Edge도 목록에 추가하려면 다음을 수행할 수 있습니다.단, Edge는 IE보다 훨씬 뛰어난 브라우저이기 때문에 추천하지 않습니다.
var ua = window.navigator.userAgent;
var isIE = /MSIE|Trident|Edge\//.test(ua);
if ( isIE ) {
//IE & Edge specific code goes here
}
값은 반환됩니다.true
Internet Explorer:
function isIE(userAgent) {
userAgent = userAgent || navigator.userAgent;
return userAgent.indexOf("MSIE ") > -1 || userAgent.indexOf("Trident/") > -1 || userAgent.indexOf("Edge/") > -1;
}
userAgent
매개 변수는 선택 사항이며 기본적으로 브라우저의 사용자 에이전트로 설정됩니다.
네비게이터 오브젝트를 사용하여 사용자 네비게이터를 검출할 수 있습니다.jquery는 필요 없습니다.아래 4개의 코멘트는 이미 포함되어 있기 때문에 이 스니펫은 예상대로 동작합니다.
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent) || navigator.userAgent.indexOf("Trident/") > -1 ){
// Do stuff with Internet-Exploders ... :)
}
http://www.javascriptkit.com/javatutors/navigator.shtml
Angularjs 팀은 다음과 같이 작업을 수행합니다(v 1.6.5).
var msie, // holds major version number for IE, or NaN if UA is not IE.
// Support: IE 9-11 only
/**
* documentMode is an IE-only property
* http://msdn.microsoft.com/en-us/library/ie/cc196988(v=vs.85).aspx
*/
msie = window.document.documentMode;
그런 다음 여러 줄의 코드가 산재하여 다음과 같은 숫자로 사용됩니다.
if (event === 'input' && msie <= 11) return false;
그리고.
if (enabled && msie < 8) {
간단하게 다음과 같이 할 수 있습니다.
var isIE = window.document.documentMode ? true : false; // this variable will hold if the current browser is IE
오래된 질문인 것은 알지만 누군가가 여기까지 스크롤하면 간단한 답변을 볼 수 있습니다.
01 법 01:
1.9 $.browser jQuery에서는 되었습니다.
if ( $.browser.msie) {
alert( "Hello! This is IE." );
}
02 법 02:
코멘트
<!--[if gte IE 8]>
<p>You're using a recent version of Internet Explorer.</p>
<![endif]-->
<!--[if lt IE 7]>
<p>Hm. You should upgrade your copy of Internet Explorer.</p>
<![endif]-->
<![if !IE]>
<p>You're not using Internet Explorer.</p>
<![endif]>
방법 03:
/**
* Returns the version of Internet Explorer or a -1
* (indicating the use of another browser).
*/
function getInternetExplorerVersion()
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
function checkVersion()
{
var msg = "You're not using Internet Explorer.";
var ver = getInternetExplorerVersion();
if ( ver > -1 )
{
if ( ver >= 8.0 )
msg = "You're using a recent copy of Internet Explorer."
else
msg = "You should upgrade your copy of Internet Explorer.";
}
alert( msg );
}
04 법 04:
DetectionJavaScript/
/*
Internet Explorer sniffer code to add class to body tag for IE version.
Can be removed if your using something like Modernizr.
*/
var ie = (function ()
{
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while (
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i>< ![endif]-->',
all[0]);
//append class to body for use with browser support
if (v > 4)
{
$('body').addClass('ie' + v);
}
}());
위의 답변 사용: 단순하고 요약된 부울 반환:
var isIE = /(MSIE|Trident\/|Edge\/)/i.test(navigator.userAgent);
브라우저가 IE11 이전 버전인지 확인하고 싶어서요. 왜냐하면 그것들은 쓰레기거든요.
function isCrappyIE() {
var ua = window.navigator.userAgent;
var crappyIE = false;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {// IE 10 or older => return version number
crappyIE = true;
}
var trident = ua.indexOf('Trident/');
if (trident > 0) {// IE 11 => return version number
crappyIE = true;
}
return crappyIE;
}
if(!isCrappyIE()){console.table('not a crappy browser);}
function detectIE() {
var ua = window.navigator.userAgent;
var ie = ua.search(/(MSIE|Trident|Edge)/);
return ie > -1;
}
modernizr 사용
Modernizr.addTest('ie', function () {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ') > 0;
var ie11 = ua.indexOf('Trident/') > 0;
var ie12 = ua.indexOf('Edge/') > 0;
return msie || ie11 || ie12;
});
또는 브라우저가 Internet Explorer일 경우 true가 반환됩니다.
function isIe() {
return window.navigator.userAgent.indexOf("MSIE ") > 0
|| !!navigator.userAgent.match(/Trident.*rv\:11\./);
}
jquery version > = 1.9 를 사용하고 있는 경우는, 이것을 시험해 주세요.
var browser;
jQuery.uaMatch = function (ua) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
/(msie) ([\w.]+)/.exec(ua) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
/(Trident)[\/]([\w.]+)/.exec(ua) || [];
return {
browser: match[1] || "",
version: match[2] || "0"
};
};
// Don't clobber any existing jQuery.browser in case it's different
if (!jQuery.browser) {
matched = jQuery.uaMatch(navigator.userAgent);
browser = {};
if (matched.browser) {
browser[matched.browser] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if (browser.chrome) {
browser.webkit = true;
} else if (browser.webkit) {
browser.safari = true;
}
jQuery.browser = browser;
}
jQuery 버전 <1.9($.browser가 jQuery 1.9에서 삭제되었습니다)를 사용하는 경우 대신 다음 코드를 사용하십시오.
$('.myClass').on('click', function (event) {
if ($.browser.msie) {
alert($.browser.version);
}
});
브라우저가 IE인지 아닌지를 검출하는 또 다른 간단한(인간이 읽을 수 있는) 기능(Edge는 전혀 나쁘지 않은 무시):
function isIE() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE '); // IE 10 or older
var trident = ua.indexOf('Trident/'); //IE 11
return (msie > 0 || trident > 0);
}
useragent를 사용하지 않으려면 브라우저가 IE인지 확인하기 위해 이 작업을 수행할 수도 있습니다.코멘트된 코드는 실제로 IE 브라우저에서 실행되며 "false"를 "true"로 바꿉니다.
var isIE = /*@cc_on!@*/false;
if(isIE){
//The browser is IE.
}else{
//The browser is NOT IE.
}
오래된 질문인 것은 알지만, IE11을 검출하는 데 문제가 있는 사람이 있을 경우에 대비해, 여기 현재의 모든 버전의 IE에 대해 유효한 솔루션이 있습니다.
var isIE = false;
if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
isIE = true;
}
이거 써봤어
function notIE(){
var ua = window.navigator.userAgent;
if (ua.indexOf('Edge/') > 0 ||
ua.indexOf('Trident/') > 0 ||
ua.indexOf('MSIE ') > 0){
return false;
}else{
return true;
}
}
네크로맨싱.
사용자 에이전트 문자열에 의존하지 않으려면 몇 가지 속성을 확인합니다.
if (document.documentMode)
{
console.log('Hello Microsoft IE User!');
}
if (!document.documentMode && window.msWriteProfilerMark) {
console.log('Hello Microsoft Edge User!');
}
if (document.documentMode || window.msWriteProfilerMark)
{
console.log('Hello Microsoft User!');
}
if (window.msWriteProfilerMark)
{
console.log('Hello Microsoft User in fewer characters!');
}
또한 새로운 Chredge/Edgium(Anaheim)을 검출합니다.
function isEdg()
{
for (var i = 0, u="Microsoft", l =u.length; i < navigator.plugins.length; i++)
{
if (navigator.plugins[i].name != null && navigator.plugins[i].name.substr(0, l) === u)
return true;
}
return false;
}
그리고 이것은 크롬을 검출한다.
function isChromium()
{
for (var i = 0, u="Chromium", l =u.length; i < navigator.plugins.length; i++)
{
if (navigator.plugins[i].name != null && navigator.plugins[i].name.substr(0, l) === u)
return true;
}
return false;
}
그리고 이 Safari:
if(window.safari)
{
console.log("Safari, yeah!");
}
@SpiderCode의 솔루션은 IE 11에서는 동작하지 않습니다.다음은 특정 기능을 위해 브라우저 검출이 필요한 코드에서 사용한 최적의 솔루션입니다.
IE11은 더 이상 MSIE로 보고되지 않으며, 이 변경 목록에 따르면 오검출을 방지하기 위한 의도적인 것입니다.
IE를 알고 싶다면 navigator.appName이 Netscape를 반환하는 경우 사용자 에이전트에서 Trident/ 문자열을 검출합니다(테스트되지 않은 것).
이 답변 덕분에
function isIE()
{
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
else if (navigator.appName == 'Netscape')
{
var ua = navigator.userAgent;
var re = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv == -1 ? false: true;
}
여기에 많은 답변이 있습니다. 제 의견을 추가하고 싶습니다.IE 11은 플렉스박스에 대해 매우 어리석었기 때문에(여기서 모든 문제와 불일치를 참조), 사용자가 IE 브라우저(11개까지 포함)를 사용하고 있는지 여부를 확인할 수 있는 쉬운 방법이 필요했습니다. Edge는 실제로 매우 좋기 때문입니다.
여기에 제시된 답변을 바탕으로 글로벌 부울 변수를 반환하는 간단한 함수를 작성했습니다. 이 함수는 다음 행에서 사용할 수 있습니다.IE를 확인하는 것은 매우 간단합니다.
var isIE;
(function() {
var ua = window.navigator.userAgent,
msie = ua.indexOf('MSIE '),
trident = ua.indexOf('Trident/');
isIE = (msie > -1 || trident > -1) ? true : false;
})();
if (isIE) {
alert("I am an Internet Explorer!");
}
이렇게 하면 검색을 한 번만 수행하면 결과를 변수에 저장할 수 있습니다. 함수 호출마다 결과를 가져올 필요가 없습니다(사용자 에이전트는 DOM과 관련이 없기 때문에 이 코드를 실행할 준비가 될 때까지 문서를 기다릴 필요도 없습니다.
아래에서는 구글을 검색하면서 우아한 방법을 찾았습니다.
/ detect IE
var IEversion = detectIE();
if (IEversion !== false) {
document.getElementById('result').innerHTML = 'IE ' + IEversion;
} else {
document.getElementById('result').innerHTML = 'NOT IE';
}
// add details to debug result
document.getElementById('details').innerHTML = window.navigator.userAgent;
/**
* detect IE
* returns version of IE or false, if browser is not Internet Explorer
*/
function detectIE() {
var ua = window.navigator.userAgent;
// Test values; Uncomment to check result …
// IE 10
// ua = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)';
// IE 11
// ua = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
// IE 12 / Spartan
// ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0';
// Edge (IE 12+)
// ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586';
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
// IE 10 or older => return version number
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
}
var trident = ua.indexOf('Trident/');
if (trident > 0) {
// IE 11 => return version number
var rv = ua.indexOf('rv:');
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
}
var edge = ua.indexOf('Edge/');
if (edge > 0) {
// Edge (IE 12+) => return version number
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
}
// other browser
return false;
}
SpiderCode의 답변으로 업데이트하여 문자열 'MSIE'가 -1을 반환하지만 'Trident'와 일치하는 문제를 해결합니다.이전에는 NAN을 반환했지만 현재는 해당 버전의 IE에서 11을 반환하고 있습니다.
function msieversion() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > -1) {
return ua.substring(msie + 5, ua.indexOf(".", msie));
} else if (navigator.userAgent.match(/Trident.*rv\:11\./)) {
return 11;
} else {
return false;
}
}
2020년에 이 페이지를 열었는데 IE5까지는 모든 userAgent 문자열이Trident
바뀐 게 있는지 모르겠어요.user에서 Trident만 체크하면 Agent가 작동했습니다.
var isIE = navigator.userAgent.indexOf('Trident') > -1;
이것은 사용자 에이전트를 확인하지 않고 IE를 검출하는 또 다른 방법입니다.
var usingIE="__IE_DEVTOOLBAR_CONSOLE_EVAL_ERROR" in document;
alert("You are"+(usingIE?"":"n't")+" using Internet Explorer.");
사이트가 IE로 동작하는지 테스트하다가 우연히 발견되어 디버거에 접속하여 폴더 아이콘을 클릭했습니다.내 대본도 있고Dynamic Scripts
제가 가지고 있지 않았던 폴더입니다.열어보니까 많은 게 있더라고요.browsertools.library.js
파일들 속에서 다음과 같은 것들을 발견했어요
document.__IE_DEVTOOLBAR_CONSOLE_EVAL_RESULT = undefined;
document.__IE_DEVTOOLBAR_CONSOLE_EVAL_ERROR = false;
document.__IE_DEVTOOLBAR_CONSOLE_EVAL_ERRORCODE = undefined;
try{
document.__IE_DEVTOOLBAR_CONSOLE_EVAL_RESULT = eval("\r\n//# sourceURL=browsertools://browsertools.library.js");
}
catch( eObj ){
document.__IE_DEVTOOLBAR_CONSOLE_EVAL_ERRORCODE = eObj.number;
document.__IE_DEVTOOLBAR_CONSOLE_EVAL_RESULT = eObj.message || eObj.description || eObj.toString();
document.__IE_DEVTOOLBAR_CONSOLE_EVAL_ERROR = true;
}
그래서 사용자의 브라우저가 IE인지 테스트하기 위해 이것을 사용했습니다.다만, 이것은 IE가 탑재되어 있는지 어떤 버전의 IE가 탑재되어 있는지 알고 싶은 경우에만 기능합니다.
모든 Internet Explorer(최종 버전 테스트 완료 12)를 검출할 수 있습니다.
<script>
var $userAgent = '';
if(/MSIE/i['test'](navigator['userAgent'])==true||/rv/i['test'](navigator['userAgent'])==true||/Edge/i['test'](navigator['userAgent'])==true){
$userAgent='ie';
} else {
$userAgent='other';
}
alert($userAgent);
</script>
https://jsfiddle.net/v7npeLwe/ 를 참조해 주세요.
function msieversion() {
var ua = window.navigator.userAgent;
console.log(ua);
var msie = ua.indexOf("MSIE ");
if (msie > -1 || navigator.userAgent.match(/Trident.*rv:11\./)) {
// If Internet Explorer, return version numbe
// You can do what you want only in IE in here.
var version_number=parseInt(ua.substring(msie + 5, ua.indexOf(".", msie)));
if (isNaN(version_number)) {
var rv_index=ua.indexOf("rv:");
version_number=parseInt(ua.substring(rv_index+3,ua.indexOf(".",rv_index)));
}
console.log(version_number);
} else {
//other browser
console.log('otherbrowser');
}
}
콘솔에 결과가 표시됩니다. Chrome Inspect를 사용하십시오.
이 코드를 Document Ready 함수에 넣었는데 Internet Explorer에서만 트리거됩니다.Internet Explorer 11에서 테스트.
var ua = window.navigator.userAgent;
ms_ie = /MSIE|Trident/.test(ua);
if ( ms_ie ) {
//Do internet explorer exclusive behaviour here
}
이것은 IE 11 이하 버전에서만 동작합니다.
var ie_version = parseInt(window.navigator.userAgent.substring(window.navigator.userAgent.indexOf("MSIE ") + 5, window.navigator.userAgent.indexOf(".", window.navigator.userAgent.indexOf("MSIE "))));
console.log("version number",ie_version);
Internet Explorer 또는 Edge 버전을 감지하는 JavaScript 함수
function ieVersion(uaString) {
uaString = uaString || navigator.userAgent;
var match = /\b(MSIE |Trident.*?rv:|Edge\/)(\d+)/.exec(uaString);
if (match) return parseInt(match[2])
}
언급URL : https://stackoverflow.com/questions/19999388/check-if-user-is-using-ie
'programing' 카테고리의 다른 글
JavaScript에서 개체 배열과 다른 값을 얻는 방법 (0) | 2023.01.15 |
---|---|
Hibernate의 MariaDB 방언 클래스 이름은 무엇입니까? (0) | 2023.01.15 |
JavaScript에는 인터페이스 타입(Java의 'interface' 등)이 있습니까? (0) | 2022.12.31 |
Django ORM에서 select_related와 prefetch_related의 차이점은 무엇입니까? (0) | 2022.12.31 |
목록 이해 대 람다 + 필터 (0) | 2022.12.31 |