简单的说是我在一文件夹里面有两个html文件1.htm 2.htm
现在我在1.htm里面想获得2.htm的所有代码。如何实现
换种说法。我在1.html里面希望实现这种功能,点击一个按钮,弹出一个alert,里面是2.html里面的html代码
因为接触html和js没多久,所以很多地方不知道,希望大家帮帮我
------解决方案--------------------
ajax
- JScript code
var xhr=window.ActiveXObject?new ActiveXObject("microsoft.xmlhttp"):new XMLHttpRequest();
alert(xhr)
xhr.open("get","2.htm",true);
xhr.onreadystatechange=function(){
if(4==xhr.readyState&&(200==xhr.status||0==xhr.status))alert(xhr.responseText);
}
xhr.send(null)