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

· 2018-11-19 (월) 11:23:04 · 2555

이전 브라우저 (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>

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

개발자팁

5,403건

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

+
분류 제목 글쓴이 날짜 조회
node.js 19-01-11 조회 2,833
node.js 19-01-10 조회 2,558
node.js 19-01-10 조회 2,656
node.js 19-01-10 조회 2,376
node.js 19-01-09 조회 2,608
node.js 19-01-09 조회 2,744
node.js 19-01-09 조회 2,987
웹서버 19-01-04 조회 3,496
PHP 18-12-18 조회 2,817
웹서버 18-12-07 조회 2,417
JavaScript 18-12-06 조회 3,175
node.js 18-11-29 조회 4,283
기타 18-11-20 조회 4,828
기타 18-11-19 조회 2,844
기타 18-11-19 조회 2,556
기타 18-11-19 조회 2,600
Mobile 18-11-09 조회 2,826
JavaScript 18-11-08 조회 2,834
기타 18-11-08 조회 2,848
jQuery 18-11-06 조회 3,085
PHP 18-10-31 조회 5,862
jQuery 18-10-29 조회 5,733
기타 18-10-12 조회 3,326
MySQL 18-10-11 조회 4,709
기타 18-10-11 조회 2,807
웹서버 18-10-07 조회 3,022
MySQL 18-10-04 조회 2,806
MySQL 18-10-02 조회 3,283
JavaScript 18-10-02 조회 1.1만
웹서버 18-09-29 조회 2,954