JavaScript
祥洋
生活很好,可以更好。
展开
-
可移动的DIV层
var obj = null;var dX = 0;var dY = 0;document.onmousemove = mouseMove;document.onmouseup = mouseUp;function mouseDown(varCurId, currEvt) { obj = document.getElementById(varCurId); if (getBrowserTy转载 2009-02-10 23:13:00 · 944 阅读 · 0 评论 -
Real-time
<!-- function get_time() { var date = new Date(); var year = "", month = "", day = "", week = "", hour = "", minute = "", second = ""; year = date.getYear(); month = add_zero(date转载 2009-09-02 20:56:00 · 516 阅读 · 0 评论 -
回车改Tab
<!-- var EventUtil = {}; EventUtil.getEvent = function() { if (window.event) { return window.event; } else { return EventUtil.getEvent.caller.arguments[0]; } }转载 2009-09-02 22:00:00 · 732 阅读 · 0 评论 -
取得字符串长度
function getStrByteLen(value) { var txt = value; txt = txt.replace(/()/ig,); txt = txt.replace(/([/u0391-/uFFE5])/ig, ); return txt.length;}转载 2009-09-04 16:47:00 · 355 阅读 · 0 评论 -
交叉色
<!-- var prevselitem = null; var color_row = null; var color_col= null; var bgcolor = "#ffff99"; function grid_mouseover_row(row原创 2009-09-25 09:53:00 · 1003 阅读 · 0 评论 -
Enter转Tab,跨过只读属性的控件
<!-- var EventUtil = {}; EventUtil.getEvent = function() { if (window.event) { return window.event; } else { return EventUtil.getEvent.c原创 2009-12-07 21:35:00 · 565 阅读 · 0 评论 -
菜单实例
Menu<!--/* common styling *//* set up the overall width of the menu div, the font and the margins */.menu { font-family: arial, sans-serif; width: 750px; margin: 0; margin: 50p转载 2009-12-15 12:31:00 · 496 阅读 · 0 评论 -
表单提示
Form Prompt <!-- /* All form elements are within the definition list for this example */ dl { font: normal 12px/15px Arial; position: relative; width: 350px; } dt {转载 2009-12-15 10:29:00 · 710 阅读 · 0 评论 -
进度条实例
正在进入 正在进入,请稍等... <!-- var bar=0 var line="||" var amount="||" count(); function count(){ bar = bar + 2; amount = amount + line documen转载 2009-12-15 12:39:00 · 388 阅读 · 0 评论 -
用js对table数据排序
sort.js // 排序 tableId: 表的id;iCol: 第几列;dataType:iCol对应的列显示数据的数据类型function sortAble(tableId, iCol, dataType) { var table = document.getElementById(tableId); var tbody = table.tBodies[0]; var colRo转载 2009-08-27 22:24:00 · 1975 阅读 · 0 评论 -
动态时间显示
function showtime() { var today, hour, second, minute, year, month, date; var strDate, n_day; today = new Date(); year = today.getFullYear(); month = today.getMonth() + 1; date = today.getDate(); ho转载 2009-04-14 08:55:00 · 441 阅读 · 0 评论 -
显示错误层
.showError { display: none; position: absolute; border: 1px solid red; background-color: #FFFF99; z-index: 1003; }--> function getBrowserType() { var varBrowser = navigator.appName if (varBr原创 2009-03-14 22:20:00 · 399 阅读 · 0 评论 -
Text获得焦点后 焦点落到文字后
function cc() { var e = event.srcElement; var r = e.createTextRange(); r.moveStart(character,e.value.length); r.collapse(true); r.select(); } function sel(obj) { var rng=obj.createTextRange(转载 2009-02-12 21:54:00 · 685 阅读 · 0 评论 -
JS判断文件是否存在
function fileCheck() { var fso; fileFullPath = fileCtrl.value; fso = new ActiveXObject("Scripting.FileSystemObject"); if (fso.FileExists(fileFullPath)) else }原创 2009-02-22 20:46:00 · 1538 阅读 · 0 评论 -
全选
function getFocus(id) { var rng = document.selection.createRange(); rng.moveStart("character", 0); rng.moveEnd("character", document.getElementById(id).value.length); rng.select();}原创 2009-02-25 23:52:00 · 335 阅读 · 0 评论 -
一些常用的正则表达式
//校验是否全由数字组成function isDigit(s){ var patrn=/^[0-9]{1,20}$/; if (!patrn.exec(s)) return false return true}//校验登录名:只能输入5-20个以字母开头、可带数字、“_”、“.”的字串function isRegisterUserName(s){ var转载 2009-02-25 23:38:00 · 421 阅读 · 0 评论 -
屏双击
var doubleClickFlg = true;function doubleClickCheck(){ if (doubleClickFlg) { doubleClickFlg = false; return true; }else{ return false; }}function resetDoubleClickFlg() { doubleClickFlg = true;}原创 2009-02-25 23:49:00 · 358 阅读 · 0 评论 -
判断上传文件是否是Excel文件
function doCheck(varCurObj) { var varCurValue = varCurObj.value; var varSufType = varCurValue.substring(varCurValue.lastIndexOf(".") + 1, varCurValue.length); if (varCurValue.length == 0) { d原创 2009-03-02 22:30:00 · 5417 阅读 · 0 评论 -
正则表达式图片文件验证
(([a-zA-Z]:)|(]{1,255})+/.(([j,J][p,P][g,G])|([g,G][i,I][f,F">//))((//)[^///*/?/|/:"]))(([a-zA-Z]:)|(]{1,255})+/.(([x,X][l,L][s,S">//))((//)[^///*/?/|/:"]))转载 2009-03-02 22:32:00 · 2140 阅读 · 0 评论 -
输入时整数和小数验证 带“,”区分
function digitCheck() { var varCurKey = String.fromCharCode(event.keyCode); var varCurRegExp = /^[0-9]{1,8}(/.[0-9]{0,2})?$/; if (varCurRegExp.test(event.srcElement.value + varCurKey) == false) { e原创 2009-03-02 00:33:00 · 539 阅读 · 0 评论 -
showModalDialog使用例子
showModalDialog使用例子父窗口向子窗口传递值,子窗口设置父窗口的值,子窗口关闭的时候返回值到父窗口,关闭刷新父窗口。 (一)showModalDialog使用例子,父窗口向子窗口传递值,子窗口设置父窗口的值,子窗口关闭的时候返回值到父窗口。 farther.html <!--function openChild() { var k转载 2009-12-20 21:29:00 · 984 阅读 · 0 评论