コードは次のとおりです。
<入力タイプ=テキストID = httpサイズ= 28 style = "color:888888" value = "http://www.haiyangtop.net">
<入力型=ボタンonclick = vbs:isexist(http.value)value = "URLが存在するかどうかの検出" style = "color:888888">
<div id = "t"> </div>
<スクリプト言語= vbs>
関数isexist(url)
dic = "c:/dic.dic"
fso = createObject( "Scripting.filesystemObject")
zidian = fso.opentextfile(dic、1、false)をset set
Zidian.AtendofStream <> trueを実行してください
path = zidian.readline
xmlhttp = createObject( "microsoft.xmlhttp")をset
xmlhttp.open "get"、http.value+path、false
xmlhttp.send
t.innerhtml = t.innerhtml&url&path& "---------"&xmlhttp.status& "<br>"
ループ
エンド関数
</script>
JSバージョンライティング:
JSを変更した場合、2行目の「onclick = vbs:isexist(http.value)」で「vbs:」を削除します
コードは次のとおりです。
<スクリプト>
関数isexist(url)
{
var myobject = new object();
myobject.lcx1 = "/admin/index.asp";
myobject.lcx2 = "/safety";
myobject.lcx3 = "/safeatex";
for(myobjectのlcx)
{
xmlhttp = new ActiveXObject( "microsoft.xmlhttp")
xmlhttp.open( "get"、http.value+myobject [lcx]、false)
xmlhttp.send()
if(xmlhttp.status == 200)
t.innerhtml+= url+myobject [lcx]+"Indess <br>";
それ以外
t.innerhtml+= url+myobject [lcx]+"存在しない<br>";
}
}
</script>
ページvbscriptバージョンに掲載されている辞書の執筆方法:
コードは次のとおりです。
<スクリプト言語= vbs>
関数isexist(url)
薄暗い
d = createObject( "Scripting.Dictionary")を設定します
d.add "a"、 "/admin/index.asp"
d.add "b"、 "/safety"
d.add "c"、 "/safetyx"
A = D.Keys
i = 0からd.count -1 'の場合、配列をトラバースします。
xmlhttp = createObject( "microsoft.xmlhttp")をset
xmlhttp.open "get"、http.value+d.item(a(i))、false
xmlhttp.send
xmlhttp.status = 200の場合
t.innerhtml = t.innerhtml+url+d.item(a(i))+"estic <br>"
それ以外
t.innerhtml = t.innerhtml+url+d.item(a(i))+"存在しない<br>"
ifを終了します
次
エンド関数
</script>
コードは次のとおりです。
<入力タイプ=テキストID = httpサイズ= 28 style = "color:888888" value = "http://www.haiyangtop.net">
<入力型=ボタンonclick = isexist(http.value)value = "推測する辞書を開く" style = "color:888888">
<div id = "t"> </div>