-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path18.html
32 lines (32 loc) · 1.12 KB
/
18.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html>
<head>
<title>自动识别网页类型</title>
<script LANGUAGE="JavaScript">
URL = window.location.href; //获取网页当前URL地址
ishtm = (URL.indexOf('.htm') > -1); //判断地址中包含的字符串
ishtml = (URL.indexOf('.html') > -1);
isshtml = (URL.indexOf('.shtml') > -1);
isphtml = (URL.indexOf('.phtml') > -1);
isaspx = (URL.indexOf('.aspx') > -1);
</script>
</head>
<body>
<script LANGUAGE="JavaScript">
//一个全局变量,用来判断网页类型
if (isphtml)
document.write("这是一个.phtml 文件!");
else if (isshtml)
document.write("这是一个.shtml 文件!");
else if (ishtml)
document.write("这是一个.html 文件!");
else if (ishtm)
document.write("这是一个.htm 文件!");
else if (aspx)
document.write("这是一个.aspx文件!");
else {
document.write("无法识别该类型文件.");
}
</script>
</body>
</html>