/*
*备注 文字限定字数
使用:onkeyup="checkLength(obj,limitNum, id)
*@param obj dom 元素
*@param limitNum 限定字数
*@param obj 提示字数长度的lable
*/
function checkLength(obj, limitNum, lable){
limitNum = limitNum || 100;//默认是100个字
if(obj.value.length > limitNum){
obj.value = obj.value.substr(0, limitNum);
return false;
}
if(lable != null && lable != ""){
$("lable").innerHTML = limitNum - obj.value.length ;
}
}
得到上下文路径
/**
* 获取上下文路径
*/
function getRootPath(){
var strFullPath=window.document.location.href;
var strPath=window.document.location.pathname;
var pos=strFullPath.indexOf(strPath);
var prePath=strFullPath.substring(0,pos);
var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1);
return(prePath+postPath);
}
自定义alert()模拟
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>提示信息</title>
<script language="javascript" type="text/javascript">
function window.onload(){
var bus=window.dialogArguments;
}
function fn_clear(){
window.returnValue = null;
window.close();
}
</script>
</head>
<body style="background-color:ButtonFace;margin:0px" scroll="no">
<table width="249" height="82" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="47"> </td>
<td width="183"> </td>
<td width="124"> </td>
</tr>
<tr>
<td><div align="right">图片</div></td>
<td colspan="2">提示信息</td>
</tr>
<tr>
<td colspan="3">
<div align="center">
<input type="submit" name="Submit" value=" 是 " width="5px" id="btn_yes">
<input type="submit" name="Submit" value=" 否 " width="5px" id="btn_no">
<input type="button" name="Submit" value="取消" width="5px" id="btn_clear" onClick="fn_clear();">
</div>
</td>
</tr>
</table>
</body>
</html>