您的位置:首页 > 理论基础 > 计算机网络

用xmlhttp判断url是否存在

2004-08-09 19:21 351 查看
///js 代码:

〈SCRIPT LANGUAGE=“JavaScript“〉
function isExist(url) {
xmlhttp = new ActiveXObject(“Microsoft.XMLHTTP“)
xmlhttp.open(“GET“,url,false)
xmlhttp.send()
if(xmlhttp.status==200)
alert(url+“ 存在“)
else
alert(url+“ 不存在“)
}
〈/SCRIPT〉
〈input type=“button“ onclick=“isExist(’http://www.sayee.com/cloudchen/js/myCalendar.htm’)“ value=“检测url是否存在“〉

///asp 代码:

Function getHTTPPage(url)
dim http
set http=Server.createobject(“Microsoft.XMLHTTP“)
Http.open “GET“,url,false
Http.send()
if Http.readystate 〈〉 4 then
exit function
else
getHTTPPage = http.status
end if
set http=nothing
if err.number〈〉0 then err.Clear
end function
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: