我想使用JavaScript实现以下功能:
所以有可能吗?如果是这样,怎么样?
顺便说一句,我不能使用服务器端技术。如果JS不适合它,在这种情况下可以使用哪些客户端技术?
答案 0 :(得分:0)
假设您想要获取源的页面位于同一个域中,您可以获得如下页面源:
if("XMLHttpRequest" in window){
xmlhttp=new XMLHttpRequest();
}
if("ActiveXObject" in window){
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
xmlhttp.open('GET', "URLofFileYouWantToGetTheSourceFrom", true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4) {
alert(xmlhttp.responseText);
}
};
xmlhttp.send(null);