Ajax JavaScript リッチクライアント HTML Webデザイン ホームページ XMLHttpRequest
<html> <head> <meta http-equiv="content-type" content="text/html;charset=Shift_JIS"> <title>ajax test</title> <script language="javascript"><!-- function getPage(pageURL) { xmlhttp = createXMLHttpRequest(); if (xmlhttp) { xmlhttp.onreadystatechange = setPageData; xmlhttp.open('GET', pageURL); xmlhttp.send(null); }else{ alert("XMLHttpRequest失敗"); } } function setPageData() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("disp").innerHTML = xmlhttp.responseText; } } //XMLHttpRequestオブジェクト生成 function createXMLHttpRequest(){ //Win ie用 if(window.ActiveXObject){ try { //MSXML2以降用 return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { //旧MSXML用 return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { return null; } } } else if(window.XMLHttpRequest){ //Win ie以外のXMLHttpRequestオブジェクト実装ブラウザ用 return new XMLHttpRequest(); } else { return null; } } // --></script> </head> <body> <form> <input type="button" value="1ページ" onClick="getPage('http://www.google.co.jp/')"> <input type="button" value="2ページ" onClick="getPage('http://www.yahoo.co.jp/')"> <input type="button" value="3ページ" onClick="getPage('http://www.infoseek.co.jp/')"> </form> <div id="disp"></div> </body> </html>
http://goodjob.boy.jp/chirashinoura/id/32.html
作成日: 2005-10-20 10:32:30
最終更新日: 2005-10-20 10:32:30
▲このページの上へ管理人: ぶらざーほわいつ 連絡