<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;
}
/* レスポンスデータ処理 */
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
/* ★全レスポンスヘッダ取得 */
var rheader=xmlhttp.getAllResponseHeaders();
if(rheader==null){
document.getElementById("res").innerHTML="レスポンスヘッダが届いていません";
}else{
document.getElementById("res").innerHTML=rheader;
}
}
}
/* HTTPリクエスト実行 */
xmlhttp.open("GET",xmlURL,true);
xmlhttp.send(null);
}
window.onload=function(){
/* ページ読み込み完了時に実行 */
testXmlHttpRequestObj("./xml/ranking.xml");
}
</script>
<div id="res"></div>