锁屏JavaScript片段
var docEle = function() {
return document.getElementById(arguments[0]) || false;
}
function cloDiv(){
var overlayID="overlay";
var msgID = "overlayMsg";
document.body.removeChild(docEle(overlayID));
document.body.removeChild(docEle(msgID));
}
function openNewDiv() {
var overlayID="overlay";
var msgID = "overlayMsg";
if (docEle(overlayID)) document.removeChild(docEle(overlayID));
if (docEle(msgID)) document.removeChild(docEle(msgID));
// 消息显示
var newDiv = document.createElement("div");
newDiv.id = msgID;
newDiv.style.position = "absolute";
newDiv.style.zIndex = "999";
newDiv.style.width = "200px";
newDiv.style.height = "30px";
var scrolltop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
var _clientheight=0;
//ie FF 在有DOCTYPE时各有区别
_clientheight = Math.min(document.body.clientHeight , document.documentElement.clientHeight);
if(_clientheight==0)
_clientheight= Math.max(document.body.clientHeight , document.documentElement.clientHeight);
var _clientwidth= document.documentElement.clientWidth || document.body.clientWidth;
//整个页面的高度
var _pageheight = Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
var msgtop = (scrolltop+((_clientheight)/2)+100)+"px";
var msgleft = (_clientwidth-200)/2+"px";
newDiv.style.top = msgtop;
newDiv.style.left =msgleft; // 屏幕居中
newDiv.style.background = "#CDCDCD";
newDiv.style.border = "1px solid #EFEFEF";
newDiv.style.padding = "5px";
newDiv.innerHTML = "正在获取Config,请稍等...";
document.body.appendChild(newDiv);
// 锁屏图层
var newMask = document.createElement("div");
newMask.id = overlayID;
newMask.style.position = "absolute";
newMask.style.zIndex = "998";
newMask.style.width = _clientwidth + "px";
newMask.sty
相关文档:
关于This
1. 它是一个关键字,并不是变量名或属性名。
2. 它实际指function所关联的对象,如果function没有关联任何对象,则this是Global对象
var msg = 'I am global';
function showMsg(){
alert(this.msg);
};
function nestedShowMsg (){
var nested = function(){
alert(this.msg);
};
nested();
......
js是弱类型的 但是某些时候 你还真需要一个date
比如说 指定时间 那么3个小时后是什么时间
这样的函数 自己写就麻烦了
转成Date
var hs = Date.parse('03/02/2009 22:10');
var d = new Date(hs);
document.write(d);
document.write('<br/>');
var h=3.5;
var arrh= ......
1. document.write( " "); 输出语句
2.JS中的注释为//
3.传统的HTML文档顺序是:document- >html- >(head,body)
4.一个浏览器窗口中的DOM顺序是:window- >(navigator,screen,history,location,document)
5.得到表单中元素的名称和值:document.getElementById( "表单中元素的ID號 ").name(或valu ......
<html>
<head>
<title></title>
</head>
<body>
<form id=aa name=aa>
<input type=button value="同意(10)" id=a1 disabled="disabled">
</form>
</body>
</html>
<script>
var num=10;
window.setTimeout("aa()",1000);
function ......
//定义要打开的对话框页面的地址 一般用action跳转要写明action的地址,如果需要参数,则在后面拼接
var urlDialog = "grpBlackWhiteManageAction.do?act=choiceMessageModel&GrpBWhiteListLevel=0";
//定义要弹出的对话框的模式,dialogWidth宽,dialogHeight高 等等
var style = "dialogWidth=600px;dialogH ......