<script type="text/javascript">
function testXmlHttpRequestObj(xmlURL){
/* XMLHttpRequestオブジェクト作成 */
var xmlhttp=false;
if(typeof ActiveXObject!="undefined"){ /* IE5, IE6 */
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); /* MSXML3 */
}
catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); /* MSXML2 */
}
}
if(!xmlhttp && typeof XMLHttpRequest!="undefined"){
xmlhttp=new XMLHttpRequest(); /* Firefox, Safari, IE7 */
}
if(!xmlhttp){
alert("XMLHttpRequest非対応ブラウザ");
return false;
}
try{
/* レスポンスデータ処理 for IE以外のブラウザ */
/* ★レスポンスデータロード完了 */
xmlhttp.onload=function(){
fGetResponseText(xmlhttp);
}
}catch(e){
/* レスポンスデータ処理 for IE */
if(typeof ActiveXObject!="undefined"){ /* IE5, IE6 */
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
fGetResponseText(xmlhttp);
}
}
}
}
/* HTTPリクエスト初期化+HTTPメソッドおよびリクエスト先URLの設定 */
xmlhttp.open("GET",xmlURL,true);
/* リクエスト送信 */
xmlhttp.send("");
}
/* レスポンスの返り値をテキスト形式で取得 */
function fGetResponseText(obj){
document.getElementById("res").innerHTML="<textarea style='width:450px; height:200px;'>"+obj.responseText+"</textarea>";
}
window.onload=function(){
/* ページ読み込み完了時に実行 */
testXmlHttpRequestObj("./xml/ranking.xml");
}
</script>
<div id="res"></div>