关于JavaScript学习过程中的一些需要注意的点~~~
来源:互联网 发布:苏州网络报警平台 编辑:程序博客网 时间:2024/05/24 15:40
1.关于一个实现数组降序排列的方法
arrayObject.sort(方法函数)
1.如果不指定<方法函数>,则按unicode码顺序排列。2.如果指定<方法函数>,则按<方法函数>所指定的排序方法排序。
<span style="color:#1f2426;"><!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Array对象 </title><script type="text/javascript"> function sortNum(a,b) {</span><span style="color:#ff0000;">//注意这里是实现降序排列的函数,关键是要注意这种方法~~</span><span style="color:#1f2426;"> return b-a; }var myarr = new Array("80","16","50","6","100","1");document.write(myarr.sort(sortNum));</script></head><body></body></html></span>
<span style="color:#1f2426;"></span>
</pre><pre name="code" class="html" style="font-family: Georgia, 'Times New Roman', Times, serif; line-height: 1.5; white-space: pre-wrap; font-size: 14px; "><span style="color:#1f2426;"></span>
</pre>2.借助定时器编写一个页面跳转
<!DOCTYPE html><html> <head> <title>浏览器对象</title> <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> </head> <body> <!--先编写好网页布局--> <h1>操作成功</h1> <br> <p><span id="sec">5</span>秒后回到主页 <a href="window.history()">返回</a></p> <script type="text/javascript"> <span style="color:#ff0000;"> //加载history列表中前一个浏览的页面</span> var count = 5; //获取显示秒数的元素,通过定时器来更改秒数。function clock(){ count--; document.getElementById("sec").innerHTML=count;<span style="color:#ff0000;">//根据id的特性选择的是innerHTML</span> if(count==0){ location.href = "http://www.imooc.com";<span style="color:#ff0000;">//location.href可以返回完整的url</span> }}var sec = setInterval(clock,1000);
<span style="font-family: 'Microsoft YaHei', SimSun, Arial; font-size: 14px; line-height: 22px; background-color: rgb(223, 222, 227); "><span style="color:#ff0000;">//在执行时,从载入页面后每隔指定的时间执行代码。</span></span><pre class="code" style="color: rgb(31, 36, 38); margin-top: 0px; margin-bottom: 0px; padding: 10px; white-space: pre-wrap; word-wrap: break-word; border: 1px solid rgb(221, 221, 221); background-color: rgb(255, 255, 255); font-family: Georgia, 'Times New Roman', Times, serif; line-height: 1.5; border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; font-size: 14px; ">
//通过window的location和history对象来控制网页的跳转。 </script> </body></html>
效果如下:
<span style="color:#1f2426;"></span>
<span style="color:#1f2426;"><!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Array对象 </title><script type="text/javascript"> function sortNum(a,b) {</span><span style="color:#ff0000;">//注意这里是实现降序排列的函数,关键是要注意这种方法~~</span><span style="color:#1f2426;"> return b-a; }var myarr = new Array("80","16","50","6","100","1");document.write(myarr.sort(sortNum));</script></head><body></body></html></span>
<span style="color:#1f2426;"></span>
</pre><pre name="code" class="html" style="font-family: Georgia, 'Times New Roman', Times, serif; line-height: 1.5; white-space: pre-wrap; font-size: 14px; "><span style="color:#1f2426;"></span>
</pre>2.借助定时器编写一个页面跳转
效果如下:<!DOCTYPE html><html> <head> <title>浏览器对象</title> <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> </head> <body> <!--先编写好网页布局--> <h1>操作成功</h1> <br> <p><span id="sec">5</span>秒后回到主页 <a href="window.history()">返回</a></p> <script type="text/javascript"> <span style="color:#ff0000;"> //加载history列表中前一个浏览的页面</span> var count = 5; //获取显示秒数的元素,通过定时器来更改秒数。function clock(){ count--; document.getElementById("sec").innerHTML=count;<span style="color:#ff0000;">//根据id的特性选择的是innerHTML</span> if(count==0){ location.href = "http://www.imooc.com";<span style="color:#ff0000;">//location.href可以返回完整的url</span> }}var sec = setInterval(clock,1000);<span style="font-family: 'Microsoft YaHei', SimSun, Arial; font-size: 14px; line-height: 22px; background-color: rgb(223, 222, 227); "><span style="color:#ff0000;">//在执行时,从载入页面后每隔指定的时间执行代码。</span></span><pre class="code" style="color: rgb(31, 36, 38); margin-top: 0px; margin-bottom: 0px; padding: 10px; white-space: pre-wrap; word-wrap: break-word; border: 1px solid rgb(221, 221, 221); background-color: rgb(255, 255, 255); font-family: Georgia, 'Times New Roman', Times, serif; line-height: 1.5; border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; font-size: 14px; ">//通过window的location和history对象来控制网页的跳转。 </script> </body></html>
<span style="color:#1f2426;"></span>
0 0
- 关于JavaScript学习过程中的一些需要注意的点~~~
- Fragment使用过程中一些需要注意的点
- 一些需要注意的点
- 关于ROS的一些需要注意的点
- Javascript学习中的一些注意点(基本语法)
- javascript中的一些核心知识点以及需要注意的地方
- 关于学习Ajax的几点需要注意的问题
- 关于Javascript变量类型的一些注意点
- Qt 一些需要注意的点
- 混合开发需要注意的一些点
- 关于addSubView需要注意的几个点
- 关于addSubView需要注意的几个点
- 关于HttpURLConnection需要注意的几点
- 关于addSubView需要注意的几个点
- 关于Java基础需要注意的点
- Javascript - 一些需要注意的细节
- javaScript中优化的一些注意点
- JavaScript数据类型的一些注意点
- 设置主菜单背景显示为壁纸
- 用htaccess url重写实现多个二级域名映射同一个空间
- 操作系统MMU简单分析
- ld: 1 duplicate symbol for architecture i386 clang: error: linker command failed with exit code 1
- uml之包图
- 关于JavaScript学习过程中的一些需要注意的点~~~
- oracle相关问题
- cocos2d-x中的curl
- JavaScript线程理解
- returned 1 exit status
- Eclipse May be locked by another process错误解决
- 如何预防病毒2
- java.lang.reflect 类 Method
- 软件项目管理的一些感想