수

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

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

이전 브라우저 (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에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
MySQL 21-04-20 조회 2,545
기타 21-04-18 조회 3,422
MySQL 21-04-17 조회 2,726
MySQL 21-04-16 조회 2,410
MySQL 21-04-15 조회 2,225
MySQL 21-04-15 조회 2,024
OS 21-03-31 조회 5,340
웹서버 21-03-24 조회 2,890
웹서버 21-03-18 조회 2,900
웹서버 21-03-11 조회 3,132
웹서버 21-03-08 조회 2,433
웹서버 21-03-02 조회 2,887
웹서버 21-03-02 조회 3,263
MySQL 21-02-25 조회 3,691
웹서버 21-02-17 조회 8,188
웹서버 21-02-13 조회 2,288
OS 21-01-20 조회 7,474
PHP 21-01-12 조회 5,402
JavaScript 21-01-12 조회 3,044
MySQL 20-11-27 조회 4,560
MySQL 20-11-25 조회 3,750
PHP 20-11-24 조회 3,013
PHP 20-11-23 조회 3,996
PHP 20-11-19 조회 5,074
PHP 20-11-13 조회 5,321
웹서버 20-09-26 조회 7,974
기타 20-08-07 조회 5,883
MySQL 20-08-05 조회 3,952
기타 20-07-15 조회 3,005
기타 20-07-14 조회 3,594