|
| » 首页 » 电脑_数码 » 编程 » 怎样用asp判断一个URL地址是否存在有效?? |
怎样用asp判断一个URL地址是否存在有效?? |
|
我用的是获取当前页面路径的办法得到对应的英或者中的页面, 可页面不是都一样的,英文里的几个也面中文没有。得到的地址肯定错误, 肯定是没有的页面,当没有这个页面的时候,就转到指定的页面,比如,回到首页,或者提示页面不存在。 用下面的办法服务器老卡死,提示连接用户过多。高人看看是什么毛病 dim str,host,url,keyword,full str="http://" host = Request.ServerVariables("HTTP_HOST") url = Request.ServerVariables("PATH_INFO")'或url keyword = Request.ServerVariables("QUERY_STRING") if keyword <> "" then full = str&host&"/English"&url&"?"&keyword else full = str&host&url end if Function testURL(urla) Dim httpxml Set httpxml = CreateObject("msxml2.XMLHTTP") httpxml.open "HEAD",urla,False httpxml.send If httpxml.status = 404 Then testURL = 0 Else testURL = 1 End If Set httpxml = Nothing End Function if testurl(full)=1 then Response.Write "页面存在" else Response.Write "页面不存在" end if js的好像很快,但是不会用 |
![]() |
|
|
|
| 《怎样用asp判断一个URL地址是否存在有效??》答案收集时间:2008-06-14 14:47:31 |