/** method : getIE() 取得控件的绝对位置
@parameter e : 控件对象(传this)
**/
function getIE(e){
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent){
t+=e.offsetTop;
l+=e.offsetLeft;
}
alert("top="+t+"/nleft="+l);
}
/** method : cursorBack() 光标是停在文本框文字的最后
提示:在文本框的<input onFocus="cursorBack()">调用
**/
function cursorBack()
{
var e = event.srcElement;
var r =e.createTextRange();
r.moveStart('character',e.value.length);
r.collapse(true);
r.select();
}
/** method : checkNum() 检查一段字符串是否全由数字组成
@parameter str : 判断的文本值
**/
function checkNum(str){return str.match(//D/)==null;}
//获得一个窗口的大小
var bodyClientWidth=0;
var bodyClientHeight=0;
function getBodySize(){
bodyClientWidth=document.body.clientWidth;
bodyClientHeight=document.body.clientHeight;
//window.srceen.width;// 得到屏幕的宽度
//window.srceen.height;// 得到屏幕的高度
}
/** method : checkChineseCharacters() 判断是否包含汉字
@parameter str : 判断的文本值
**/
function checkChineseCharacters(str){
if(/[^/x00-/xff]/g.test(str)){
alert("含有汉字");
}else{
alert("不包含汉字");
}
}
/** method : cursorMoveNext() ENTER键可以让光标移到下一个输入框--onkeydown事件
提示:在文本框的<input onKeyPress="cursorMoveNext()">调用
**/
function cursorMoveNext(){
if(event.keyCode==13)event.keyCode=9;
}
/** method : isNumeric() 检查是否为任意数(实数)
@parameter strNumber : 判断的文本值
**/
function isNumeric(strNumber)
{
var newPar=/^(-|/+)?/d+(/./d+)?$/;
alert(newPar.test(strNumber));
}
/** method : checkInfo(),checkInfoPoint(),checkInfoLine()对文本框输入数据限制的3种方式
提示:在文本框的<input onkeydown="方法名()">调用
**/
function checkInfo()
{
if(event.keyCode==13){
event.keyCode=9;
}else if("0123456789".indexOf(String.fromCharCode(window.event.keyCode))==-1)
window.event.returnValue=false;
}
function checkInfoPoint()
{
if(event.keyCode==13){
event.keyCode=9;
}else if("0123456789.".indexOf(String.fromCharCode(window.event.keyCode))==-1)
window.event.returnValue=false;
}
function checkInfoLine()
{
if(event.keyCode==13){
event.keyCode=9;
}else if("0123456789-".indexOf(String.fromCharCode(window.event.keyCode))==-1)
window.event.returnValue=false;
}
/** method : IsClose()关闭窗体前提示
提示:在窗体的<body onbeforeunload="IsClose()">调用
**/
function IsClose(){
if(!(event.clientX<document.body.clientWidth&&event.clientY<0||event.altKey)){
window.event.returnValue="友情提示!";
}
}
/** method : checkEmail()判断Email地址
@parameter str : 判断的文本值
**/
function checkEmail(str){
alert(//w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*/.test(str));
}
/** method : Exists()判断文件是否存在
@parameter filespec : 文件的路径
**/
function Exists(filespec)
{
if (filespec)
{
var fso;
fso = new ActiveXObject("Scripting.FileSystemObject");
alert(fso.FileExists(filespec));
}
}
/** method : selectText() 获得当前的文本框选中的文字
提示:在文本框的<input onKeyUp="selectText()">调用
**/
function selectText(){
alert(document.selection.createRange().text)
}
/** method : addTr() 动态为表格添加行
@parameter objTable : 表格的id名
**/
function addTr(objTable){
var newTr=objTable.insertRow();//添加行
var newTd=newTr.insertCell();//添加列
newTd.innerHTML="<input name='aa'>";
}
/** method : getrow() 获得当前的行是表格的第几行
提示:在表格的<table onClick="getrow()">调用
**/
var index=-1;
function getrow()
{
if(event.srcElement.tagName=="TD"){
curRow=event.srcElement.parentElement;
index=curRow.rowIndex;
alert("这是TD第"+(curRow.rowIndex+1)+"行");
}
}
/** method : deleteTr() 动态删除表格行
@parameter objTable : 表格的id名
提示:和前面的getrow()方法连用
**/
function deleteTr(objTable){
if(index<0){
alert("请选择要删除的行,再进行删除!");
return false;
}
objTable.deleteRow(index);
index=-1;
}
/** method : trim() 去空格
@parameter text: 要去掉空格的文本值
**/
function trim(text)
{
text = text.replace(/^ +/, "");
text = text.replace(/ +$/, "");
return text;
}
//关闭输入法
//<input style="ime-mode:disabled">

被折叠的 条评论
为什么被折叠?



