1.

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <title>标题页</title>
 7 </head>
 8 <body >
 9 <SCRIPT LANGUAGE="JavaScript">
10     URL = window.location.href;   //获取网页当前URL地址
11     alert(URL.indexOf('.jsp'));
12     ishtm = (URL.indexOf('.htm') > -1);    //判断地址中包含的字符串
13     ishtml = (URL.indexOf('.html') > -1);
14     isshtml = (URL.indexOf('.shtml') > -1);
15     isphtml = (URL.indexOf('.phtml') > -1);
16     isaspx = (URL.indexOf('.aspx') > -1);
17     isjsp = (URL.indexOf('.jsp') != -1);
18     alert(isjsp);
19 //一个全局变量,用来判断网页类型
20 if (isjsp)
21     document.write("这是一个.jsp文件!");
22 else { 
23 document.write("无法识别该类型文件.");
24 }
25 </script>
26 </body>
27 </html>

 

posted on 2017-02-27 00:34  Sharpest  阅读(1993)  评论(0)    收藏  举报