<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <button id="btn" οnclick="showHellow(prompt('次数'))">点击</button> </body> <script> /*/!*形式参数 没有具体的值,数据由时机参数决定*!/ var showMessage = function(name,age,sex){ alert(name+":"+age+":"+sex) }; /!*实际参数,实参,实参会影响形式参数*!/ showMessage("d","d","sd");*/ /*自调用匿名函数*/ /* ( function(name){ alert(name); })("ccy");*/ /*function showHellow(account){ for(var i=0;i<account;i++){ alert("Hellow!"); } } var arr = [1,2,3,4,5,6,34,6,8,43,23,44]; var length = arr.length; for (var i = 0;i < length; i++){ alert(arr[i]); }*/ var person = { /*对象的属性*/ name:"许光祥", age:35, /*对象的方法*/ eat:function(food) { alert("我喜欢"+food); } }; alert(person.name); alert(person.age); person.eat("饼干"); </script> </html> <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> </body> <script> var sum=0; function sumth (account){ for(var i=1;i<=account;i++){ sum+=i; } return sum; } alert(sumth(parseInt( prompt('请输入累加的最大数')))); </script> </html> <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>递归求和</title> </head> <body> </body> <script> /* function show(name1,name2){ alert(name1); alert(name2); } show("xgg","lsy");*/ var sum1=0; function calc(num){ for(var i = 1;i <= num; i++){ sum1+=i; } return sum1; } var result1=calc(10); alert(result1); var sum2=0; function calc2(num){ if(num <= 10){ sum2 += num; num++; calc2(num);/*递归*/ /*arguments.callee(num);用这个相当于calc(num),效果是一样的。*/ } return sum2; } var result2 = calc2(10); alert(result2); /*F12调试: * F10:一步步执行,遇到方法,一步执行完,无法查看方法的执行情况。 * F11:一步步执行,遇到方法,进入到方法法内部,可以查看方法的具体执行情况。 * shift+F11:从当前的方法退出。 * F8:停止当前的调试 * 在调试的watch里可以添加变量监听。 * breakpoints:断电的清理,可以单个清理,常用的是一次清理全部。*/ </script> </html> <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>windows</title> </head> <body> </body> <script> //也可以不加window。 console.log(window.screen);//获取屏幕宽度高度。 console.log(window.screen.width);//屏幕宽度 console.log(window.screen.height);//屏幕高度 console.log(window.screen.availHeight);//可用高度 console.log(window.screen.availWidth);//可用宽度 console.log(window.history);//有关客户反问过的url信息 console.log(window.location);//有关当前url的信息 console.log(window.closed);//当窗口关闭时为真 console.log(window.document);//窗口中当前显示的文档对象 console.log(window.opener);//打开当前窗口的窗口 console.log(window.self);//指示当前窗口 console.log(window.defaultStatus);//窗口底部显示的默认状态信息 console.log(window.status);//描述用户交互导致的状态栏的临时信息 </script> </html> <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>location常用属性</title> </head> <body> </body> <script> console.log(window.location.hash);//设置或返回从#开始的url(锚) console.log(window.location.host);//设置或返回主机名和当前url的端口号 console.log(window.location.hostname);//主机名 console.log(window.location.href);//设置或返回完整的url console.log(window.location.pathname);// console.log(window.location.port);//端口号 console.log(window.location.protocol);//url协议部分 console.log(window.location.search);//以后的协议部分 location.assign()//加载新的文档 location.reload()//重新加载当前文档 location.replace()//用新的文档替换当前文档 /*以上三个属性的应用,重点。*/ </script> </html> <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>confirm</title> </head> <body> </body> <script> var age = prompt("请输入你的年龄:"); alert(age); var f = confirm("确定要删除本条数据吗?");//点击确定返回true,点击取消返回forth if(f){ alert("您取消成功了。"); }else{ alert("您取消了删除操作。"); } </script> </html>
HTML5第十三课时汇总
最新推荐文章于 2022-12-03 16:55:37 发布