///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
〈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
博客提供了检测URL是否存在的代码。包含JavaScript代码,通过创建ActiveXObject对象发送请求,根据状态码判断URL是否存在;还给出了ASP代码,利用Server.createobject创建对象,根据状态判断并返回结果。

5516

被折叠的 条评论
为什么被折叠?



