}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
http_request.onreadystatechange = function()
{
if (http_request.readyState == 4) {
if (http_request.status == 200) {
updateObj(obj,http_request.responseText);
}
else
{
updateObj(obj,"");
}
}
}
http_request.open('GET', url, true);
http_request.send(null);
}
function updateObj(obj,data){
obj.innerHTML = data;
}
function $(url){
var obj = document.getElementById("content");
obj.style.display='block';
document.getElementById("container").style.margin="10px auto 0px";
obj.innerHTML = "Loading…";
makeRequest(obj,url);
}
html调用方法:
<a href="#" onclick="$('news.html')">新闻</a><a href="#" onclick="$('product.html')">产品</a><a href="#" onclick="$('case.html')">案例</a><a href="#" onclick="$('contact.html')">联系</a><a href="http://zj55com.cnblogs.com/" target="_blank">博客</a>









