<html>
<head>
<title>辨別檔案類型</title>

<SCRIPT LANGUAGE="JavaScript">
URL = window.location.href; //首先獲取網址
ishtm = (URL.indexOf('.htm') > -1); //使用URL.indexOF()來判斷網址中是否包含某字串
ishtml = (URL.indexOf('.html') > -1);
isphp = (URL.indexOf('.php') > -1);
isasp = (URL.indexOf('.asp') > -1);
</script>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
//顯示是什麼檔案
if (ishtm)
document.write("是htm!");
else if (ishtml)
document.write("是html!");
else if (isphp)
document.write("是php!");
else if (isasp)
document.write("是asp!");
else {
document.write("需要人工判斷.");
}
</script>

arrow
arrow
    文章標籤
    javascript extensiona
    全站熱搜

    痞客興 發表在 痞客邦 留言(0) 人氣()