1.Confim
在html标记添加确认,加上
onclick="return confirm('您确定要删除这个数据吗?')"

在js方法里添加确认,加上
if(confirm('确定要删除选中的数据吗?'))
{
     document.listForm.submit();
}


2.可用与不可用
在html标记里添加disabled表示当前控件不可用,readonly表示当前控件只读,enabled表示当前控件可用。
在js方法里通过disabled=true表示某空间不可用。

3.浏览器回退
window.history.back();


4.限制输入框长度
在html标记里添加maxlength="500"。
//限制textArea的长度
onkeyup="return limitMaxLength(this)"
function limitMaxLength(obj){
  var mlength = obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
  if (obj.getAttribute && obj.value.length > mlength){
    obj.value = obj.value.substring(0,mlength);
  }
}


5.设置页面不被浏览器缓存
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta http-equiv="Cache-Control" content="no-store"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>



6.修改样式名称
object.className="";


7.显示和隐藏
object.style.display="none";//隐藏
object.style.display="";//显示


8.刷新页面
1 history.go(0) 
2 location.reload() 
3 location=location 
4 location.assign(location) 
5 document.execCommand(‘Refresh‘) 
6 window.navigate(location) 
7 location.replace(location) 
8 document.URL=location.href.自动刷新页面的方法:
1.页面自动刷新:把如下代码加入<head>区域中<meta http-equiv="refresh" content="20">其中20指每隔20秒刷新一次页面.
2.<body onload="opener.location.reload()"> 开窗时刷新
3.<body onUnload="opener.location.reload()"> 关闭时刷新


9.使用锚
使用锚(mao)可以定位到页面的某个地方
格式:URL+#+元素的ID(最好是<a>的ID),
例子:http://www.google.com#edit。
http://www.google.com页面里有一个<a id="edit"></a>的元素

10.定时执行JS函数
setInterval("pushIDSEvent()",5000);//间隔5秒
  • date.rar (2.5 KB)
  • 描述: 日期JS函数: Date.prototype.isLeapYear 判断闰年 Date.prototype.Format 日期格式化 Date.prototype.DateAdd 日期计算 Date.prototype.DateDiff 比较日期差 Date.prototype.toString 日期转字符串 Date.prototype.toArray 日期分割为数组 Date.prototype.DatePart 取日期的部分信息 Date.prototype.MaxDayOfDate
  • 下载次数: 2
评论
发表评论

提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则

您还没有登录,请登录后发表评论

fantasy
搜索本博客
最近加入圈子
存档
最新评论