이전 브라우저 (IE5 및 IE6)  XMLHttpRequest 객체 사용

· 7년 전 · 2013

이전 브라우저 (IE5 및 IE6)  XMLHttpRequest 객체 사용

 

이전 버전의 Internet Explorer (5/6)는 XMLHttpRequest 객체 대신 ActiveX 객체를 사용합니다.

variable = new ActiveXObject("Microsoft.XMLHTTP");
IE5 및 IE6을 처리하려면 브라우저에서 XMLHttpRequest 객체를 지원하는지 확인하거나 ActiveX 객체를 만듭니다.

 


if (window.XMLHttpRequest) {
    // code for modern browsers
    xmlhttp = new XMLHttpRequest();
 } else {
    // code for old IE browsers
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}


소스

<!DOCTYPE html>
<html>
<body>

<h2>The XMLHttpRequest Object</h2>

<p id="demo">Let AJAX change this text.</p>

<button type="button" onclick="loadDoc()">Change Content</button>

<script>
function loadDoc() {
  var xhttp;
  if (window.XMLHttpRequest) {
    // code for modern browsers
    xhttp = new XMLHttpRequest();
    } else {
    // code for IE6, IE5
    xhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("demo").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "ajax_info.txt", true);
  xhttp.send();
}
</script>

</body>
</html>

|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

개발자팁

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
node.js 7년 전 조회 2,261
node.js 7년 전 조회 2,027
node.js 7년 전 조회 2,088
node.js 7년 전 조회 1,811
node.js 7년 전 조회 2,064
node.js 7년 전 조회 2,241
node.js 7년 전 조회 2,449
웹서버 7년 전 조회 2,955
PHP 7년 전 조회 2,229
웹서버 7년 전 조회 1,941
JavaScript 7년 전 조회 2,643
node.js 7년 전 조회 3,748
기타 7년 전 조회 4,254
기타 7년 전 조회 2,290
기타 7년 전 조회 2,014
기타 7년 전 조회 2,041
Mobile 7년 전 조회 2,329
JavaScript 7년 전 조회 2,313
기타 7년 전 조회 2,299
jQuery 7년 전 조회 2,570
PHP 7년 전 조회 5,278
jQuery 7년 전 조회 5,196
기타 7년 전 조회 2,761
MySQL 7년 전 조회 4,143
기타 7년 전 조회 2,288
웹서버 7년 전 조회 2,490
MySQL 7년 전 조회 2,252
MySQL 7년 전 조회 2,680
JavaScript 7년 전 조회 9,872
웹서버 7년 전 조회 2,395
🐛 버그신고