📄 newdiv.js
字号:
//公有变量,用来记录初始弹出的位置及大小
var initialwidth,initialheight,initialleft,initialtop;
var mouseX,mouseY;
//若Client浏览器为IE5.0以上版本的
var ie5=document.all&&document.getElementById;
//若Client浏览器为NetsCape6。0版本以上的
var ns6=document.getElementById&&!document.all;
//弹出浮动框遮罩层
function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function shade(txt){
var shadediv = document.createElement("DIV");
shadediv.id = "shadediv";
shadediv.style.position = "absolute";
shadediv.style.left = "0px";
shadediv.style.top = "0px";
shadediv.style.width = iecompattest().clientWidth+"px";//宽
shadediv.style.height = iecompattest().scrollHeight+"px";//高
shadediv.style.background = "#000000";//背景颜色
shadediv.style.textAlign = "center";
shadediv.style.zIndex = "9999";//浮动z轴
shadediv.style.filter = "alpha(opacity=15)";//透明度
shadediv.style.opacity = 0.8;
shadediv.innerHTML = txt;
document.body.appendChild(shadediv);
}
function centerDiv(obj,flag){
if (typeof (obj) == 'string'){
obj = document.getElementById ( obj );
}
if(obj){
try{
obj.style.left = ( 0 - (obj.clientWidth-iecompattest().clientWidth)/ 2 + iecompattest().scrollLeft ) + 'px';
obj.style.top = ( 0 - (obj.clientHeight-iecompattest().clientHeight) / 2 + iecompattest().scrollTop ) + 'px';
}
catch (e){}
if(flag){
setTimeout ( "centerDiv('" + obj.id + "',1)", 100 );
}
}
}
//得到横坐标纵坐标
function getXY(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
var posx=parseInt(offsetx) +parseInt(iecompattest().scrollLeft);
var posy=parseInt(offsety) +parseInt(iecompattest().scrollTop);
mouseX=posx;
mouseY=posy;
}
//弹出浮动窗口
//width宽,height高,positions位置,0表示指定位置 需添加left与top参数,1表示居中,2表示鼠标位置适合
function loadwindow(obj,divwidth,divheight,positions,divleft,divtop){
shade('');//遮罩
//document.getElementById(obj).style.width=width+"px";
initialwidth=divwidth+"px";
//document.getElementById(obj).style.height=height+"px";
initialheight=divheight+"px";
with (document.getElementById(obj).style){
position="absolute";
zIndex="10000";
divwidth?width=divwidth+"px":'';
divheight?height=divheight+"px":'';
}
if(positions==0){
document.getElementById(obj).style.left=divleft;
document.getElementById(obj).style.top=divyop;
}
else if(positions==1){
centerDiv(obj,divleft);
}
else if(positions==2){
getXY(divleft);
if(mouseX+parseInt(divwidth)>iecompattest().clientWidth){
document.getElementById(obj).style.left=mouseX-parseInt(divwidth);
}
else{
document.getElementById(obj).style.left=mouseX;
}
if(mouseY+parseInt(divheight)>iecompattest().clientHeight){
document.getElementById(obj).style.top=mouseY-parseInt(divheight);
}
else{
document.getElementById(obj).style.left=mouseY;
}
}
}
var dragapproved=false
var minrestore=0 //该变量表示窗口目前的状态,0表示初始化状态,1表示最大化状态
//document.getElementById(obj).style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px";
//if (!ie5&&!ns6) //若不为IE或Netscpae浏览器,则使用一般的Window.open进行弹出窗口处理
//window.open(url,"","width=width,height=height,scrollbars=1")
//{
//}
//else{
//}
//this.doOk = function(){
//document.body.removeChild(shadediv);
//.getElementById("do_OK").focus();
function maximize(obj){
if (minrestore==0){
minrestore=1;//maximize window
document.getElementById(obj).style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById(obj).style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
document.getElementById(obj).style.filter="blendTrans(Duration=5)";
document.getElementById('dwindow_2').style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
}
else{
minrestore=0; //restore window
document.getElementById(obj).style.width=initialwidth;
document.getElementById(obj).style.height=initialheight;
document.getElementById('dwindow_2').style.width=initialwidth;
//alert(initialwidth);
//document.getElementById('dwindow_2').style.height=initialheight;
}
document.getElementById(obj).style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById(obj).style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}
function closeit(){
if(FlagRunBuild==1){
var shadediv=document.getElementById('shadediv');
var showdiv=document.getElementById('showdiv');
document.body.removeChild(shadediv);
document.body.removeChild(showdiv);
FlagRunBuild=0;
}
}
var FlagRunBuild=0;
function build(){
FlagRunBuild=1;
var str="<div id='dwindow' style='position:absolute;border:1px solid #3b6097;background:#EBEBEB;left:0px;top:0px;'>";
//str+="<div id='dwindow_2' style=\"text-align:right;padding-right:10px;background:#3b6097;\">";
//str+="<span style='float:left;border-width:0px;color:#ffffff;line-height:20px;display:inline;'> build</span> ";
//str+="<span style='width:40px;border-width:0px;color:#ffffff;cursor:hand;line-height:20px;display:inline;'onClick=\"maximize('dwindow')\">最大化</span> ";
//str+="<span style='width:40px;border-width:0px;color:#ffffff;cursor:hand;line-height:20px;display:inline;'onClick=\"closeit()\">关 闭</span>";
//str+="</div>";
str+="<div id='dwindowcontent'><img src='../template/default/img/loading.gif'></div>";
str+="</div>";
var showdiv = document.createElement("DIV");
showdiv.innerHTML = str;
showdiv.id = "showdiv";
document.body.appendChild(showdiv);
loadwindow('dwindow',0,0,1,1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -