为了账号安全,请及时绑定邮箱和手机立即绑定
慕课网数字资源数据库体验端
JavaScript进阶篇_学习笔记_慕课网
为了账号安全,请及时绑定邮箱和手机立即绑定

JavaScript进阶篇

慕课官方号 页面重构设计
难度入门
时长 8小时55分
  • var i=setInterval("func()",time); clearInterval(i);
    查看全部
  • var myarr=new Array(); //定义数组
    查看全部
  • <!DOCTYPE html> <html> <head> <title>浏览器对象</title> <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> </head> <body> <!--先编写好网页布局--> <h1>操作成功</h1> <span id="second">5</span>秒后回到主页 <a href="javascript:back()">返回</a> <script type="text/javascript"> var sec=document.getElementById("second"); var i=sec.innerHTML; var timer=setInterval( function (){ i--; sec.innerHTML = i; if (i==1){ location.assign("http://www.imooc.com/") } },1000); //获取显示秒数的元素,通过定时器来更改秒数。 //通过window的location和history对象来控制网页的跳转。 function back(){ window.history.back(); } </script> </body> </html>
    查看全部
    0 采集 收起 来源:编程练习

    2018-03-22

  • 返回前一个浏览的页面 back()方法,加载 history 列表中的前一个 URL。 语法: window.history.back(); 比如,返回前一个浏览的页面,代码如下: window.history.back(); 注意:等同于点击浏览器的倒退按钮。 back()相当于go(-1),代码如下: window.history.go(-1);
    查看全部
  • 随机数 random() random() 方法可返回介于 0 ~ 1(大于或等于 0 但小于 1 )之间的一个随机数。 语法: Math.random(); 注意:返回一个大于或等于 0 但小于 1 的符号为正的数字值。 我们取得介于 0 到 1 之间的一个随机数,代码如下: <script type="text/javascript"> document.write(Math.random()); </script> 运行结果: 0.190305486195328 注意:因为是随机数,所以每次运行结果不一样,但是0 ~ 1的数值。 获得0 ~ 10之间的随机数,代码如下: <script type="text/javascript"> document.write((Math.random())*10); </script> 运行结果: 8.72153625893887
    查看全部
    0 采集 收起 来源:随机数 random()

    2018-03-22

  • 四舍五入round() round() 方法可把一个数字四舍五入为最接近的整数。 语法: Math.round(x) 参数说明: 注意: 1. 返回与 x 最接近的整数。 2. 对于 0.5,该方法将进行上舍入。(5.5 将舍入为 6) 3. 如果 x 与两侧整数同等接近,则结果接近 +∞方向的数字值 。(如 -5.5 将舍入为 -5; -5.52 将舍入为 -6). 把不同的数舍入为最接近的整数,代码如下: <script type="text/javascript"> document.write(Math.round(1.6)+ "<br>"); document.write(Math.round(2.5)+ "<br>"); document.write(Math.round(0.49)+ "<br>"); document.write(Math.round(-6.4)+ "<br>"); document.write(Math.round(-6.6)); </script> 运行结果: 2 3 0 -6 -7
    查看全部
    0 采集 收起 来源:四舍五入round()

    2018-03-22

  • History 对象 history对象记录了用户曾经浏览过的页面(URL),并可以实现浏览器前进与后退相似导航的功能。 注意:从窗口被打开的那一刻开始记录,每个浏览器窗口、每个标签页乃至每个框架,都有自己的history对象与特定的window对象关联。 语法: window.history.[属性|方法] 注意:window可以省略。 History 对象属性: length:返回浏览器历史列表中的URL数量 History 对象方法: (1) back() 加载history列表中的前一个URL (2) forward() 加载history列表中的下一个URL (3) go() 加载history列表中的某个具体的页面 使用length属性,当前窗口的浏览历史总长度,代码如下: <script type="text/javascript"> var HL = window.history.length; document.write(HL); </script>
    查看全部
    0 采集 收起 来源:History 对象

    2018-03-22

  • 错的,误点
    查看全部
    0 采集 收起 来源:编程练习

    2015-04-01

  • 向下取整floor() floor() 方法可对一个数进行向下取整。 语法: Math.floor(x) 参数说明: 注意:返回的是小于或等于x,并且与x最接近的整数。 我们将在不同的数字上使用 floor() 方法,代码如下: <script type="text/javascript"> document.write(Math.floor(0.8)+ "<br>") document.write(Math.floor(6.3)+ "<br>") document.write(Math.floor(5)+ "<br>") document.write(Math.floor(3.5)+ "<br>") document.write(Math.floor(-5.1)+ "<br>") document.write(Math.floor(-5.9)) </script> 运行结果: 0 6 5 3 -6 -6
    查看全部
    0 采集 收起 来源:向下取整floor()

    2018-03-22

  • 在自己的编辑器浏览能生效,为何在此就无法生效?
    查看全部
  • 返回浏览历史中的其他页面 go()方法,根据当前所处的页面,加载 history 列表中的某个具体的页面。 语法: window.history.go(number); 参数: 浏览器中,返回当前页面之前浏览过的第二个历史页面,代码如下: window.history.go(-2); 注意:和在浏览器中单击两次后退按钮操作一样。 同理,返回当前页面之后浏览过的第三个历史页面,代码如下: window.history.go(3);
    查看全部
  • 代码结果
    查看全部
  • <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>计时器</title> <script type="text/javascript"> var attime; function clock() { var time = new Date(); attime = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds(); document.getElementById("clock").value = attime; } var s=setInterval(clock, 1000); // setInterval("clock()",1000); 1s=1000ms document.getElementById("stop").onclick = function() { clearInterval(s); } </script> </head> <body> <form> <input type="text" id="clock" size="50" /> <input type="button" value="Stop" id="stop" /> </form> </body> </html>
    查看全部
  • onUnload
    查看全部
  • 返回下一个浏览的页面 forward()方法,加载 history 列表中的下一个 URL。 如果倒退之后,再想回到倒退之前浏览的页面,则可以使用forward()方法,代码如下: window.history.forward(); 注意:等价点击前进按钮。 forward()相当于go(1),代码如下: window.history.go(1);
    查看全部

举报

0/150
提交
取消
课程须知
你需要具备HTML、css基础知识,建议同学们也可以想学习下js入门篇,快速认识js,熟悉js基本语法,更加快速入手进阶篇!
老师告诉你能学到什么?
通过JavaScript学习,掌握基本语法,制作简单交互式页面
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!