📄 alphadiv.js
字号:
// JavaScript Document
/********************************************************************
主题:透明遮罩层样式脚本
作者:Issac
日期:Sep.2005
说明:
1.调用initAlpha(oTab);
2.问题:Mozilla下尚不支持若干方法.
********************************************************************/
var centerZIndex = 1000;
var alphaValue;
document.write("<div id=\"alphaBox\" style=\"display: none;\">");
document.write("<div id=\"alphaPop\"></div>");
document.write("<div id=\"alphaBg\"></div>");
document.write("</div>");
//主函数
function initAlpha(oTab) {
document.getElementById("alphaBox").style.display = "block";
alphaPop(oTab);
alphaValue = 0;
alphaBg();
movePop();
}
//关闭层函数
function closeAlpha(){
document.getElementById("alphaBox").style.display = "none";
}
//判断是否为IE的简易脚本
function isIE(){
return document.all;
}
//中间浮动层固定样式
function alphaPop(oTab) {
with (document.getElementById("alphaPop")){
innerHTML="<table>"+document.getElementById(oTab).innerHTML+"</table>"; //适用于Mozilla(此处不直接用outerHTML)
var popDivHight = offsetHeight;
var popDivWidth = offsetWidth;
with (style) {
position = "absolute";
top = "50%";
left = "50%";
zIndex = centerZIndex;
marginTop = -0.5 * popDivHight + "px";
marginLeft = -0.5 * popDivWidth + "px";
}
}
}
//底部遮罩层固定样式
function alphaBg(){
if (alphaValue<=18)
alphaValue = alphaValue + 3;
with (document.getElementById("alphaBg").style) {
position = "absolute";
top = "0px";
left = "0px";
zIndex = centerZIndex - 1;
background = "#000";
if (isIE()) {
height = document.body.clientHeight;
width = document.body.clientWidth;
filter = "Alpha(Opacity="+alphaValue+")";
}
else {
height = "100%";
width = "100%";
MozOpacity = alphaValue/100;
}
}
setTimeout("alphaBg()",100);
}
//拖动浮动层函数
function movePop(){
with (document.getElementById("alphaMove"))
{
var X, Y;
onmousedown = function(){
X = event.x - document.getElementById("alphaPop").style.pixelLeft;
Y = event.y - document.getElementById("alphaPop").style.pixelTop;
setCapture();
}
onmouseup = function(){
releaseCapture();
}
onmousemove = function(){
if(event.button == 1) {
var myX = document.getElementById("alphaPop").clientLeft;
var myY = document.getElementById("alphaPop").clientTop;
document.getElementById("alphaPop").style.pixelLeft = myX + (event.x - X);
document.getElementById("alphaPop").style.pixelTop = myY + (event.y - Y);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -