<html>
<head>
<title>弹出窗口(可拖动,背景灰色透明)</title>
<link href="http://localhost:12964/Content/bootstrap.css" rel="stylesheet" />
<script src="http://localhost:12964/Scripts/jquery-1.10.2.js"></script>
<script src="http://localhost:12964/Scripts/bootstrap.js"></script>
<script src="http://localhost:12964/Scripts/Channel/popover.ladder.js"></script>
<script type="text/javascript">
<!--
/*FileName:AlertMsg.js
title:提示标题
content:提示的内容*/
function AlertMsg(title, content) {
var ev = window.event;
var mousePos = mouseCoords(ev);
console.log("AlertMsg")
if (document.getElementById("msgdiv") != null) return;
var msgw,msgh,msgbg,msgcolor,bordercolor,titlecolor,titlebg,con;
con = "";
//弹出窗口设置
msgw = 300; //窗口宽度
msgh = 150; //窗口高度
msgbg = "#FFFF66"; //内容背景
msgcolor = "#000"; //内容颜色
bordercolor = "#D9DA97"; //边框颜色
titlecolor = "#FFF"; //标题颜色
titlebg = "#369"; //标题背景
//遮罩背景设置
var sWidth,sHeight;
sWidth = screen.availWidth;
sHeight = document.body.scrollHeight;
//创建遮罩背景
var maskObj = document.createElement("div");
maskObj.setAttribute('id','maskdiv');
maskObj.style.position = "absolute";
maskObj.style.top = "0";
maskObj.style.left = "0";
maskObj.style.background = "#777";
maskObj.style.filter = "Alpha(opacity=30);";
maskObj.style.opacity = "0.3";
maskObj.style.width = sWidth + "px";
maskObj.style.height = sHeight + "px";
maskObj.style.zIndex = "10000";
//创建弹出窗口
var msgObj = document.createElement("div")
msgObj.setAttribute("id","msgdiv");
msgObj.style.position ="absolute";
msgObj.style.top = mousePos.y + "px";
msgObj.style.left = mousePos.x + "px";
msgObj.style.width = msgw + "px";
msgObj.style.height = msgh + "px";
msgObj.style.fontSize = "12px";
msgObj.style.background = msgbg;
msgObj.style.border = "1px solid " + bordercolor;
msgObj.style.zIndex = "10001";
//创建内容
var bodyObj = document.createElement("div");
bodyObj.setAttribute("id","msgbody");
bodyObj.style.padding = "10px";
bodyObj.style.lineHeight = "1.5em";
bodyObj.innerHTML = content;
//生成窗口
//document.body.appendChild(maskObj);
document.body.appendChild(msgObj);
document.getElementById("msgdiv").appendChild(bodyObj);
}
function CloseMsg() {
console.log("CloseMsg")
//移除对象
var bodyObj = document.getElementById("msgbody");
var msgObj = document.getElementById("msgdiv");
var maskObj = document.getElementById("maskdiv");
if(null!=bodyObj&&null!=msgObj){
msgObj.removeChild(bodyObj);
}
if(null!=msgObj){
document.body.removeChild(msgObj);
}
if(null!=maskObj){
document.body.removeChild(maskObj);
}
}
function mouseCoords(ev) {
if (ev.pageX || ev.pageY) {
return { x: ev.pageX, y: ev.pageY };
}
return {
x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y: ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
</script>
</head>
<body>
<div style="background-color:red" οnmοusemοve="AlertMsg('', '<div><div class=\'popUpTest\'></div>')" οnmοuseοut=" CloseMsg()">点我试试!</div>
</body>
</html>