关于JavaScript学习过程中的一些需要注意的点~~~
2014-05-30 11:09
417 查看
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>
相关文章推荐
- JavaScript使用过程中需要注意的地方和一些基本语法
- JavaScript使用过程中需要注意的地方和一些基本语法
- c++中 关于字符串的一些需要注意的问题
- 3DMAX导出插件开发过程中需要注意的一些地方
- 学习php过程中的一些注意点的总结
- 有关于eclipse配置spket需要注意的一些地方
- 由于自己的需要搜集的一些关于 “ javascript实现图片的不间断连续滚动” 的代码
- 电路系统设计制作过程和需要注意的一些问题
- 11月28日-- 关于数据库存储过程的一些学习
- 电路系统设计制作过程和需要注意的一些问题
- 关于block的一些需要注意的地方
- 关于SelectOjbect使用需要注意的一些问题
- 关于静默安装需要注意的一些问题(转)
- C++程序员在学习C#时需要注意的一些问题(一)
- 嵌入式开发学习笔记(YL2440,一些需要注意的地方)
- JavaScript使用过程中的注意点和一些基本语法
- 关于学习Ajax的几点需要注意的问题
- 数据恢复过程中需要注意的一些问题
- 学习php过程中的一些注意点的总结
- 有关于eclipse配置spket需要注意的一些地方