[转]js判断url是否有效
时间:2014-01-20 19:21:50
收藏:0
阅读:434
本文转自:http://www.cnblogs.com/fumj/p/3490121.html
方法一:(仅适用于ie)
function CheckStatus(url) { XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP") XMLHTTP.open("HEAD",url,false) XMLHTTP.send() return XMLHTTP.status==200 } function NetPing() { return CheckStatus("http://www.163.com/index.html"); }
方法二:(利用jquery,适用所有浏览器)
function NetPing() { $.ajax({ type: "GET", cache: false, url: "http://www.163.com/index.html", data: "", success: function() { Done(1); }, error: function() { Done(0); } }); }
原文:http://www.cnblogs.com/freeliver54/p/3526454.html
评论(0)
