共包含 日期格式, url提取及分解,对象 三部分内容
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>JavaScript语法</title>
-
-
- </head>
- <script type="text/javascript">
- <!--
- var thisDate = new Date();
-
- document.writeln(thisDate.toString());
- document.writeln("<br/>");
- document.write(thisDate.getFullYear() + "-" + thisDate.getMonth() + "-" + thisDate.getDay());
- document.writeln(" ");
- document.writeln(thisDate.getHours() + ":" + thisDate.getMinutes() + ":" + thisDate.getSeconds() + "." + thisDate.getMilliseconds() );
-
- document.write("<hr/>");
-
- var url = document.URL.split("?");
- var param = url[1].split("&");
- for(i = 0; i < param.length; i++){
- var val = param[i].split("=");
- document.write(val[0] + "=" + val[1]);
- document.write("<br/>");
- }
-
-
- document.write("<hr/>");
- document.write("<input type='button' value='New document' onclick='newDocument()'/>");
- function newDocument(){
- document.open();
- document.write("New Document");
- window.setTimeout(window.close(), "3000");
- }
-
-
-
-
-
-
-
-
-
-
- function Person(){
- this.name = 'aa';
- this.age = 12;
- this.say = sayPerson;
- this.ageAdd=function(){
- this.age++;
- }
- }
- function sayPerson(){
- alert(this.name + "," + this.age + "," + this.addr);
- }
- function newP(){
- var p = new Person();
- p.addr = "abcd";
- p.say();
- p.ageAdd();
- p.say();
- }
-
-
- function cHuman(){
- function sayHuman(attr){
- return human[attr];
- }
- var human = new Object();
- human.userName = "abc";
- human.userAge = 12;
- alert(sayHuman("userAge"));
- alert(sayHuman("userName"));
- }
-
-
- function Simon(){this.userName; this.userAge;}
-
- Simon.prototype.setUserName = function(userName){this.userName = userName;}
- Simon.prototype.getUserName = function(){return this.userName;}
- Simon.prototype.setUserAge = function(userAge){this.userAge = userAge;}
- Simon.prototype.getUserAge = function(){return this.userAge;}
- function cSimon(){
-