![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JavaScript
apple_wxs
这个作者很懒,什么都没留下…
展开
-
window.setTimeout() 和window.setInterval() 使用说明
setTimeout()的使用: 先看个例子 [code="js"] function test() { //100毫秒后执行sleep方法, 但这100毫秒程序不会等待,会继续执行setTimeout后面的代码 //效果就是 先alert(2); 后 alert(1); window.setTimeout("sleep()", 100); alert(2); } ...2008-11-27 16:20:03 · 340 阅读 · 0 评论 -
找某个控件的坐标动态显示div(支持ie和ff)
看下面的例子,里面提供了一个得到元素绝对位置(坐标)的方法getElementPos(obj) [code="js"] I am div ^_^ 点击showDiv按钮在文本框下面出现一个DIV aa showDiv ...2008-12-19 20:11:09 · 142 阅读 · 0 评论 -
Js中sort()方法的用法
sort(sortfunction)为javascript的数组对象(Array)的一个方法,提供排序功能 参数 sortFunction 为可选项,是用来确定排序原则的js函数, 这个函数有两个参数,分别代表每次排序比较时的两个数组项, 如果这个函数的返回值小于0 则不交换原数组中元素的位置,否则交换原数组中元素的位置。 如果这个参数被省略, 那么元素将按照 ASCII 字符顺序进行...2008-12-19 19:45:22 · 102 阅读 · 0 评论 -
函数作为构造函数执行 和 作为普通函数执行的区别
看下面js代码 [code="js"] function dwn(s) { document.write(s + ""); } function Double(value) { dwn(arguments.callee); dwn(this.constructor); return parseFloat(value); } var ...2008-12-17 20:43:23 · 153 阅读 · 0 评论 -
闭包外面 () 的含义
[code="js"](function(){ alert("abc"); })();[/code] 等价于 [code="js"]var f = function(){ alert("abc") } f();[/code]2008-12-16 21:35:12 · 105 阅读 · 0 评论 -
window.location的属性
[b]属性 [/b] [b]描述 [/b] hash 设置或获取 href 属性中在井号“#”后面的分段。 host 设置或获取 location 或 URL 的 hostname 和 port 号码。 hostname 设置或获取 location 或 URL 的主机名称部分。 href ...2008-12-15 15:52:05 · 109 阅读 · 0 评论 -
声明式函数 与 函数表达式 的解析顺序
看这两个例子 [code="html"] 声明式函数 与 函数表达式 的解析顺序1 文档加载运行前,声明式函数最先被解析器解析,而函数表达式 是代码运行到它那行时,它才被解析 另外 如果文档中含有 多个同名的 声明式函数,则以文档后面的为准,因为代码从前向后找,如果有同名,会用后面的覆盖前面的 这里,虽然文档加载运行前,声明式函数t1先被解析器解析, 但是当文档开...2008-12-14 15:45:38 · 212 阅读 · 0 评论 -
in 的用法
利用in的特性可以将对象当作一个集合来使用,对象的属性作为集合的元素。 [code="js"]//定义一对象 var point = {x:20, y:30}; alert("x" in point);//true alert("toString" in point);//true 继承属性 alert("z" in point);//false for (var i in ...2008-12-08 20:23:19 · 220 阅读 · 0 评论 -
运算符 && 和 || 的返回值
今天才知道,原来 && 和|| 的返回值是这样计算的 &&首先计算其左边的表达式,如果它的值为false或可被转换为false(null、NaN、0或undefined),那么将返回左边表达式的值,否则,它将计算右边的表达式, 并返回这个表达式结果作为 &&运算的结果。 ||首先计算其左边的表达式,如果它的值不为false或不可被转换为false(null、NaN、0或undefined),那...2008-12-08 20:18:31 · 239 阅读 · 0 评论 -
typeof 运算符
[code="js"] var arr = new Array(); var myf = function(){}; //typeof 后面如果是 表达式,必须加() alert("typeof 1 = " + typeof 1);//number alert("typeof (\"1\" - 0) = " + typeof ("1"- 0));//number al...2008-12-08 20:06:17 · 95 阅读 · 0 评论 -
with 语句使用
[code="html"] with 语句使用 one two with (document.forms[0]) { myText.value = "hello world"; mySelect.value = 2; myCheckbox.checked = true; } ...2008-12-08 20:04:26 · 78 阅读 · 0 评论 -
for in 用法
[code="js"] /** * for in 循环,每次取的是obj对象 的 key 值。 */ //得到对象的keys集合 // in 左边的可以是表达式, function keys(obj) { var ret = new Array(); var i = 0; for (ret[i++] in obj); retu...2008-12-08 20:02:36 · 703 阅读 · 0 评论 -
保证页面整体只有一对滚动条
当页面中有frame的时候,而且frame的高度、宽带动态变化时,页面有时会出现多个滚动条,视觉效果很差,用下面两个js语句就能很好的解决这个问题了。 [code="js"]document.body.scrollHeight; document.body.scrollWidth;[/code] 举个例子 index.html里有个iframe,里面是xx.html [code="inde...2008-12-04 10:44:51 · 137 阅读 · 0 评论 -
访问 iframe 的信息
index.html 里 有个iframe,指向xx.html [code="html"] function test(){ alert("iframe的 src=" + document.all.bottom.src); alert("xx.html 里的js变量aa=" + bottom.aa); alert("xx.html 里的input的值mytext.val...2008-11-29 18:11:15 · 93 阅读 · 0 评论 -
删除select 里的 option
[code="html"] a b c [/code]2009-01-29 21:26:33 · 291 阅读 · 0 评论