Javscript全局函数
Javscript全局函数
1、自定义的$()函数
JS代码:
function $(strid){
var element = document.getElementById(strid);
if (element){
return element;
}
else
{
return null;
}
}
2、回车键
1、自定义的$()函数
JS代码:
function $(strid){
var element = document.getElementById(strid);
if (element){
return element;
}
else
{
return null;
}
}
2、回车键
//have key down
function haveKeyDown(e,method)
{
var pressedKey;
if (!e) e = window.event;
if (document.all){
pressedKey = e.keyCode;
}
else{
pressedKey = e.which;
}
//alert(pressedKey);
if (pressedKey == 13) {
if (islogin) {
method.call(this,$("txtEdit").value);
}
}
}
//have key up
function haveKeyUp(e)
{
var pressedKey;
if (!e) e = window.event;
if (document.all){
pressedKey = e.keyCode;
}
else{
pressedKey = e.which;
}
if (pressedKey == 13) {
if (islogin) {
$("txtEdit").innerHTML ="";
}
}
}
"唯有高屋建瓴,方可水到渠成"