P19
认识html
帧
_blank弹出新帧
_self指向本帧
_parent父帧
_top最顶层帧
P61
未定义undefined
document.write("hello"+"/n");
document.write("name/'tree/'");
数组
week=new Array{"sunday","monday"};
document.write(week);
<body οnlοad="f()">
onunload
P131第五章,js内置对象
month=new Array();
delete month[2];
P141
Array对象的属性和方法
P146
String对象的方法
charAt(num)
var name="tree";
name.bold();
name.toUpperCase();
name.fontsize(6);
name.substring(0,4);
使用Date对象
today=new Date();
year=today.getFullYear();
month=today.getMonth()+1;
day=today.getDate();
theweek=today.getDay();
getHours();getMinutes();getSeconds();
Global对象和Number对象
P165
第六章,document对象
P178止
P193window对象和frame对象
P218止表单对象
练习代码一
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head>
- <title>无标题页</title>
- <script type="text/javascript">
- function f(){
- //alert("hello");
- name=event.type;
- alert(name);
- }
- //document.form1.btn1.onclick=f;
- function nomenu(){
- alert("不能用快捷菜单");
- event.returnValue=false;
- }
- function before(){
- alert("before");
- }
- function after(){
- alert("after");
- }
- function check(){
- var txt=document.getElementById("i1");
- alert(txt.value());
- }
- function createwindow(){
- window.open("js_test.htm","mywindow","menubar=no,height=200,width=300");
- }
- document.onclick=function(){
- createwindow();
- }
- </script>
- </head>
- <body oncontextmenu="nomenu();"><!--oncontextmenu属性必须删除第一行-->
- <form method="post" name="form1" action="js_test.htm" onsubmit="check();">
- <input type="button" name="btn1" value="hello" />
- <input id="i1" type="text" onblur="after();" onfocus="before();" />
- <input type="submit" value="submit" />
- </form>
- </body>
- </html>
练习代码二
- <!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>
- <title>读书笔记《javascript边学边用》</title>
- <script type="text/javascript">
- function f(){
- var i = "20";
- var j = 11;
- var k = j + i;
- var m= Number(i) + j;
- alert(k+'||'+m);
- week=new Array("sunday","monday");
- document.write(week);
- document.write(week.length);
- //document.write("name/'tree/'");
- }
- function f1(){
- num = prompt("enter:");
- alert(num);
- }
- function f2(){
- var con;
- con=confirm("是/否");
- if(con==true)
- alert("是");
- else
- alert("否");
- }
- function f3(msg){
- var answer=prompt(msg,"www.163.com");
- if(answer==null)alert("no");
- else alert("yes"+answer);
- }
- function f4(){
- var i = Math.PI*2;
- alert(i);
- }
- function f5(){
- for(var i in document){
- document.writeln(i+"<br/>");
- }
- }
- function f6(){
- with(Math){//Math.sin(30)省了.
- var i = sin(30);
- alert(i);
- }
- }
- function f7(){
- var data=new Array("1","2");
- Array.prototype.fun=fun;
- data.fun();
- }
- function fun(){
- alert("fun");
- }
- function f8(){
- var c1=new Array("1","2");
- var c2=new Array("3","4");
- var c3=c1.concat(c2);
- alert(c3);
- }
- function f9(){
- var c1=new Array("1","8");
- var c2=new Array("3","4");
- var c3=c1.concat(c2);
- c3.sort();
- alert(c3);
- }
- function f10(){
- var i = eval("1+2");
- alert(i);
- }
- function f11(){
- newnewfun=new Function("x","y","z=x+y;return z");
- var x=Number(22);
- var y=Number(11);
- alert(newfun(11,y));
- }
- document.onclick=function(){
- //alert('');
- // f1();
- // f3("hello");
- f11();
- }
- </script>
- </head>
- <body>
- <div>
- <a href="#i1">i1</a>
- <ul>
- <li>List Item</li>
- <li>hello</li>
- <li>hello</li>
- </ul>
- <ol>
- <li>hello</li>
- <li>hello</li>
- <li>hello</li>
- </ol>
- <pre>
- 原样输出 空格
- 回车
- </pre>
- <a name="i1">i1</a>
- </div>
- <form id="f1" action="HTMLPage.htm" method="post">
- <input name="txt" type="text" />
- <input type="submit" />
- </form>
- </body>
- </html>