07 2012 档案

摘要:js 与 jsp 一起工作:begin.jsp<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/& 阅读全文
posted @ 2012-07-31 23:00 allenbackpacker 编辑
摘要:<!DOCTYPE html><html> <head> <title>js23.html</title> <script type="text/javascript"> var today = new Date(); var expireDay = new Date(); var msPerMonth = 24*60*60*1000*31; expireDay.setTime(today.getTime()+msPerMonth); document.cookie... 阅读全文
posted @ 2012-07-31 22:00 allenbackpacker 编辑
摘要:element 对象:<!DOCTYPE html><html> <head> <title>js22.html</title> <script type="text/javascript"> function moveNext(object, index) { if (object.value.length == 4) { document.forms[0].elements[index+1].focus(); } } func... 阅读全文
posted @ 2012-07-30 22:56 allenbackpacker 编辑
摘要:Javascript 中的 document.links 对象可以计算一共有多少个 link<!DOCTYPE html><html> <head> <title>js21.html</title> <script type="text/javascript"> function linkGetter() { alert(document.links.length+"个搜索引擎"); for (var i = 0; i < document.links.length; i++) 阅读全文
posted @ 2012-07-30 22:34 allenbackpacker 编辑
摘要:Javascript 中的 location 对象<!DOCTYPE html><html> <head> <title>js20.html</title> </head> <body onload="setInterval('countDown()', 1000);"> <script type="text/javascript"> var sec = 5; function countDown() { if (sec >0) { do 阅读全文
posted @ 2012-07-30 22:18 allenbackpacker 编辑
摘要:Javascript 中的 history对象第一个html页面: js18.html<!DOCTYPE html><html> <head> <title>js18.html</title> </head> <body> <a href="js19.html">js19.html</a> </body></html>第二个html页面: js19.html<!DOCTYPE html><html> <head&g 阅读全文
posted @ 2012-07-30 21:18 allenbackpacker 编辑
摘要:js绑定事件2种方法:1. <input type = "button" onclick="clickHandler()">2. 该方法必须掌握<input type = "button" id="button1"><script type = "text/javascript">var v = document.getElementById("button1");v.onclick=clickHandler; //注意,没有括号</ 阅读全文
posted @ 2012-07-29 08:07 allenbackpacker 编辑
摘要:事件,一旦离开鼠标<!DOCTYPE html><html><head> <script type="text/javascript"> function checkPassword(object) { if(object.value.length <=4) { alert("密码长度过短。"); object.focus(); //选中对象 object.select(); //选中全部内容 } ... 阅读全文
posted @ 2012-07-29 07:30 allenbackpacker 编辑
摘要:定时器1:setTimeout()<!DOCTYPE html><html> <head> <title>js12.html</title> <script type="text/javascript"> function count() { setTimeout("alert('执行成功')",2000); //两秒钟后执行 alert } </script> </head> <body> <input type = &qu 阅读全文
posted @ 2012-07-28 22:17 allenbackpacker 编辑
摘要:Javascript 中的事件触发<!DOCTYPE html><html> <head> <title>js11.html</title> <script type="text/javascript"> function mouseOver(object) { object.color = "red"; } function mouseOut(object) { object.color = "blue"; ... 阅读全文
posted @ 2012-07-28 22:10 allenbackpacker 编辑
摘要:Javascript 中的 对象调用<!DOCTYPE html><html> <head> <title>js9.html</title> </head> <body> <script type="text/javascript"> function member(name,gender) { this.name = name; this.gender = gender; } var m1 = new me... 阅读全文
posted @ 2012-07-28 22:08 allenbackpacker 编辑
摘要:字符串<!DOCTYPE html><html> <head> <title>js7.html</title> </head> <body> <script type="text/javascript"> var str = "javascript"; var num = 1234; with (document) { write(str.toUpperCase()+"<br>"); write(num.toString().c 阅读全文
posted @ 2012-07-27 22:41 allenbackpacker 编辑
摘要:Javascript 中的 Array 是可以变长,变类型的。比如 Array中第一个元素是整型,第二个是 boolean型。<!DOCTYPE html><html> <head> <title>js4.html</title> </head> <body> <script type="text/javascript"> var fruits = new Array("apple", "鸭梨", "tomato"); 阅读全文
posted @ 2012-07-26 23:42 allenbackpacker 编辑
摘要:Javascript 中的 Date.getMonth() 返回值是 0 -11Date.getDay() 的返回值为 0-6。其中周日是0。 阅读全文
posted @ 2012-07-26 23:27 allenbackpacker 编辑
摘要:for ... in 语句:重复执行制定对象的所有属性。格式:for (变量 in 对象){}<!DOCTYPE html><html> <head> <title>js3.html</title> </head> <body> <script type="text/javascript"> function member(name, gender) //不需要加 var给 name 或 gender.该 member()是个构造函数 { this.name = name; // 阅读全文
posted @ 2012-07-26 23:12 allenbackpacker 编辑
摘要:如下:<!DOCTYPE html><html> <head> <title>js2.html</title> </head> <body> <script type="text/javascript"> with (document) { write("<ol>"); write("<li>hello</li>"); write("<li>world</li>" 阅读全文
posted @ 2012-07-26 22:59 allenbackpacker 编辑
摘要:Javascript 中一般用 var 来定义变量。也可以不用var定义变量。但是二者还是有区别的。我们看这个<html><head><title>js1.html</title><script type="text/javascript"> var globe = "globe"; //globe 在 function()外边,肯定是全局变量。 test(); //调用 test() function test() { globe2 = "globe2"; //这里的 gl 阅读全文
posted @ 2012-07-26 22:48 allenbackpacker 编辑