发布网友 发布时间:2022-07-01 16:20
共1个回答
热心网友 时间:2023-10-21 01:29
楼上根本没明白你的PHP是做什么的
先引用jquery,然后下面两段script放到后面
<script language="javascript">
//上移
function getSource(url){
var dex = url.indexOf("?");
if(dex == -1){
url = url + "?timestampt=" + new Date();
} else {
url = url + "×tampt=" + new Date();
}
send_request(url, callbackGetSource);
}
function callbackGetSource(){
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var t = http_request.responseText
alert(t);
} else { //页面不正常
alert("您所请求的页面有异常。");
}
}
}
</script>
<!-- ajax -->
<script language="javascript">
var http_request = null;
function send_request(url, method) {
http_request = null;
if(window.XMLHttpRequest) { //Mozilla 浏览器
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {//设置MiME类别
http_request.overrideMimeType('text/xml');
}
} 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) { // 异常,创建对象实例失败
window.alert("不能创建XMLHttpRequest对象实例.");
return false;
}
http_request.onreadystatechange = method;
http_request.open("GET", url, true);
http_request.send(null);
}
</script>
调用方式是:
<input type="button" value="获取目标网页源码" οnclick="javascript:getSource('http://checkip.dyndns.com/')">
==========引用资料==========
网页链接