js 基础

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type="text/javascript" src="./jquery-1.7.2.js"></script>
</head>

<body>
	js 输出
	<br />
	<script type="text/javascript">
		document.write("helloworld");
	</script>
	<script type="text/javascript">
		document.write("<h1>HelloWorld</h1>");
	</script>
	<input type="button" value="点我" οnclick="javascript:alert('北京欢迎你');" />
	<br />

	<script type="text/javascript">
		document.write(" 未知数据类型");
		var obj;
		document.write(obj);
		document.write("<br/>");
		document.write("空值");
		var n=null;
		document.write(n);
		document.write("<br/>");
		var num=10;
		document.write(typeof(num));
		document.write("<br/>");
		
		var str="你好吗";
		document.write(typeof(str));
		document.write("<br/>");
		var b=false;
		document.write(typeof(b));
		
		var str2="abcABC";
		document.write("<br/>");
		document.write(str2.toUpperCase());
		document.write("<br/>");
		document.write(str2.toLowerCase());
		document.write("<br/>");
		
		//下标从0开始
		document.write(str2.charAt(3)); 
		// 要查找的字符        起始位置 
		document.write(str2.indexOf('a',0));
		//顾头不顾尾
		document.write(str2.substring(0,1));
		
		var str3="123,a,v";
		document.write(str3.split(',')[0]);
		var c=str3.split(',');
		for( var i=0;i<c.length;i++){
			document.write(c[i]);
			document.write("<br/>");
		}
		
		var ar=new Array(10);
		for(var i=0; i<ar.length;i++){
			ar[i]=i;
		}
		for(var i=0; i<ar.length;i++){
			document.write(ar[i]);
		}
		document.write(ar.join('*'));
		 ar.push("放入");
			for(var i=0; i<ar.length;i++){
				document.write(ar[i]);
			}
		document.write("for in");
		for(var i in ar){
			document.write(i);
		}

		var j="111";
		
		document.write(typeof(j));
		document.write(isNaN(j));
		j=parseInt(j);
		document.write(isNaN(j));
		document.write(typeof(j));
	</script>
	
	<script type="text/javascript">
		function p(){
			var result= ("哈哈","你好");
			document.write(result);
		}	
		var n=function (){
			alert("匿名函数");
		};
		
		function c(){
			var r=confirm("是否要删除");
			if(r){
				alert("删除成功");
			}else{
				alert("删除失败");
			}
		}
		function w(){
			window.open("hello.jsp","hello","  ");
		}
		function l(){
			alert(location.host);
			alert(location.href);
			alert(location.hostname);
			location.reload();
		}
		function d(){
			var date=new Date();
			alert(date);
			
		}
		var t1,t2;
		function t(){
			document.getElementById("t").innerHTML=new Date().getHours()+":"+new Date().getMinutes()+":"+new Date().getSeconds();
			t1=setTimeout(t, 1000);
		}
		
		function t3(){
			
			document.getElementById("t2").innerHTML=new Date().getHours()+":"+new Date().getMinutes()+":"+new Date().getSeconds();
		}
		function t2(){
			t2=setInterval(t3, 1000);
		}
		function ct1(){
			clearTimeout(t1);
		}
		function ct2(){
			clearInterval(t2);
		}
	</script>
	<input type="button" value="提示框" οnclick="p()"/>
	<br/>
	<input type="button" value="匿名函数" οnclick="n()"/>       
	<br/>
	<input type="button" value="confirm" οnclick="c()"/>       
	<br/>
	<input type="button" value="打开窗口" οnclick="w()"/>       
	<br/>
	<input type="button" value="location" οnclick="l()"/>       
	<br/>
	<input type="button" value="riqi" οnclick="d()"/>       
	<input type="button" value="时间" οnclick="t()"/>       
	<input type="button" value="时间2" οnclick="t2()"/>       
	<input type="button" value="清楚1" οnclick="ct1()"/>       
	<input type="button" value="清除2" οnclick="ct2()"/>       
	    <h1 style="color: red" id="t"></h1>                                                 
	    <h1 style="color:green" id="t2"></h1>                                                 
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值