Javascript 数组学习一则
1. 应用 Array.prototype.join实现字符合并
方法1.
String.prototype.times = function(n) {
return Array.prototype.join.call({length:n+1}, this);
};
"js".times(5) // => "jsjsjsjsjs"
方法2.
var ArrayTest=new Array("HE","LL","O");
var hello = Array.prototype.join.call(ArrayTest, '|');
alert(hello); // => "HE|LL|O");
2.字符串分割成数组
var _param = "HE||LL||O";
var _paramArray = _param.split("|");
alert(_paramArray.length)
相关文档:
JavaScript 事件方法
http://www.webdeveloping.cn/blog/?action=show&id=207
事件源对象
event.srcElement.tagName
event.srcElement.type
捕获释放
event.srcElement.setCapture();
event.srcElement.releaseCapture();
事件按键
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
事件返回值
......
一段JavaScript脚本程序,负责关闭窗口,如果网页不是通过脚本程序打开的(window.open()),调用window.close()脚本关闭窗口前,必须先将window.opener对象置为null,否则浏览器(IE7、IE8)会弹出一个确定关闭的对话框。
<script language="javaScript">
function closeWindow()
{
window.opener = null;
w ......
关于
JavaScript
正则表达对象的使用,其参考手册介绍如下:
语法 1
re = /
pattern
/
[flags
]
语法 2
re = new RegExp("
pattern
",
["
flags
"
])
参数
re
必选项。将要赋值为正则表达式模式的变量名。
Pattern
必选项。要使用的正则表达式模式。如果使用语法 1
,用 &q ......
Evaluates an expression after a specified number of milliseconds has elapsed.
(在指定时间过后执行指定的表达式)
Syntax:
iTimerID = window.setTimeout(vCode, iMilliSeconds [, sLanguage])
Parameters
vCode
Required. Variant that specifies the function pointer or string that indicates the code to be ......