总结JAVASCRIPT和HTML基础
1.Confim
在html标记添加确认,加上
onclick="return confirm('您确定要删除这个数据吗?')"if(confirm('确定要删除选中的数据吗?')){ document.listForm.submit();}window.history.back();
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); }}<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"/>
object.className="";
object.style.display="none";//隐藏object.style.display="";//显示
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()"> 关闭时刷新
onkeydown="javascript:if(event.keyCode==13){alert(1);return false;}"<script language="javascript"> function enterkey(eventTag) { var event = eventTag||window.event; var currentKey = event.charCode||event.keyCode;if (currentKey==13) { // do something. alert(currentKey);event.returnValue= false; // 取消此事件的默认操作 } } </script> <body> <input type="text" id="corpName" onkeydown="enterkey(event);" /></body>