<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>弹出窗口测试</title>
<script language="javascript" src="JS/Alert.js" type="text/javascript"></script>
<link rel="Stylesheet" href="css/alert.css" />
</head>
<body>
<form action="#">
<a href="#" οnclick="AlertWindow(document.getElementById('alertwindow'),400,'常用短信','cancel');">
弹出</a>
<div class="hide" id="alertwindow">
<p>
sdfdfdfdfdf</p>
<p>
<select>
<option>你好</option>
<option>没问题</option>
</select>
</p>
</div>
</form>
</body>
</html>
var ALERT_TITLE = "客户关系管理";
var ALERT_BUTTON_TEXT = "确 定";
var ALERT_BUTTON_CANCEL = "取 消";
function AlertWindow(popdiv, width, title, types)
{
AlertWindow(popdiv, width, title, types, null);
}
function AlertWindow(popdiv, width, title, types, hidbtnId)
{
var d = document;
if(d.getElementById("mainControl")) return;
//遮盖页面的幕
var screend = d.createElement("div");
screend.id = "gp_screen";
screend.style.zIndex = 999;
screend.style.width = window.screen.width - 22 + "px";
screend.style.height = window.screen.height - 226 + "px";
screend.onclick = function(){WindowClose(popdiv, bodyControl)};
d.getElementsByTagName("body")[0].appendChild(screend);
//声明总窗体
var mainControl = d.getElementsByTagName("form")[0].appendChild(d.createElement("div"));
mainControl.id = "mainControl";
mainControl.style.zIndex = 1000;
mainControl.className = "dragclass";
mainControl.style.width = width + "px";
//声明窗体的头部
var mainHead = mainControl.appendChild(d.createElement("div"));
mainHead.id = "HeadControl";
mainHead.appendChild(d.createTextNode(ALERT_TITLE + "——" + title));
//声明窗体的内容部分,并加载内容
var bodyControl = mainControl.appendChild(d.createElement("div"));
bodyControl.id = "BodyControl";
bodyControl.style.width = width - 20 + "px";
while(popdiv.childNodes.length > 0)
{
bodyControl.appendChild(popdiv.childNodes[0]);
}
//声明头部的关闭按钮
var closewindow = d.createElement("a");
closewindow.href = "#";
closewindow.style.left = width - 20 + "px";
//closewindow.style.top = 2 + "px";
closewindow.id = "x";
closewindow.style.zIndex = 1002;
//closewindow.innerHTML = "x";
closewindow.onclick = function() {WindowClose(popdiv, bodyControl)};
mainControl.appendChild(closewindow);
//声明窗体的脚部,并加载“取定,取消按钮”
/*var footControl = mainControl.appendChild(d.createElement("div"));
footControl.id = "FootControl";
footControl.style.width = width;
if(types.indexOf("OK") >= 0)
{
var btnOK = d.createElement("input");
btnOK.type = "button";
btnOK.id = "closeBtn";
btnOK.value = ALERT_BUTTON_TEXT;
btnOK.onclick = function(){WindowSubmit(popdiv, hidbtnId);}
footControl.appendChild(btnOK);
}
if(types.indexOf("Cancel") >= 0)
{
var btnCancel = d.createElement("input");
btnCancel.type = "button";
btnCancel.value = ALERT_BUTTON_CANCEL;
btnCancel.onclick = function() {WindowClose(popdiv, bodyControl)};
footControl.appendChild(btnCancel);
}*/
//取消页面的select的显示
var sels = document.getElementsByTagName("select");
for(i = 0; i < sels.length; i ++)
{
if(sels[i].style.visibility == "")
{
sels[i].style.visibility = "hidden";
}
}
var thesels = mainControl.getElementsByTagName("select");
for(i = 0; i < thesels.length; i ++)
{
if(thesels[i].style.visibility == "hidden")
{
thesels[i].style.visibility = "";
}
}
drogdron();
}
function WindowClose(popdiv, bodyControl)
{
while(bodyControl.childNodes.length > 0)
{
popdiv.appendChild(bodyControl.childNodes[0]);
}
document.getElementsByTagName("form")[0].removeChild(document.getElementById("mainControl"));
document.getElementsByTagName("body")[0].removeChild(document.getElementById("gp_screen"));
//显示页面上的select
var sels = document.getElementsByTagName("select");
for(i = 0; i < sels.length; i ++)
{
if(sels[i].style.visibility == "hidden")
{
sels[i].style.visibility = "";
}
}
if(document.getElementById("ChkId") != null)
{
document.getElementById(document.getElementById("ChkId").value).parentNode.parentNode.style.backgroundColor = "#E9FDE8";
document.getElementById(document.getElementById("ChkId").value).checked = false;
}
return false;
}
function WindowSubmit(popdiv, hidbtnId)
{
popdiv.innerHTML = document.getElementById("BodyControl").innerHTML;
WindowClose();
if(hidbtnId != null)
{
document.getElementById(hidbtnId).onclick();
}
return false;
}
function gs(d)
{
var t=document.getElementById(d);
if (t)
{
return t.style;
}
else
{
return null;
}
}
function gs2(d,a)
{
if (d.currentStyle){
var curVal=d.currentStyle[a]
}else{
var curVal=document.defaultView.getComputedStyle(d, null)[a]
}
return curVal;
}
function drogdron()
{
if (document.getElementById)
{
(
function()
{
if (window.opera)
{
document.write("<input type='hidden' id='Q' value=' '>");
}
var n = 1000;
var dragok = false;
var y,x,d,dy,dx;
function move(e)
{
if (!e) e = window.event;
if (dragok)
{
d.style.left = dx + e.clientX - x + "px";
d.style.top = dy + e.clientY - y + "px";
return false;
}
}
function down(e)
{
if (!e) e = window.event;
var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
if (temp.tagName != "HTML"|"BODY" && temp.className != "dragclass")
{
temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
}
if('TR'==temp.tagName)
{
temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
}
if (temp.className == "dragclass")
{
if (window.opera)
{
document.getElementById("Q").focus();
}
dragok = true;
temp.style.zIndex = n++;
d = temp;
dx = parseInt(gs2(temp,"left"))|0;
dy = parseInt(gs2(temp,"top"))|0;
x = e.clientX;
y = e.clientY;
document.onmousemove = move;
return false;
}
}
function up()
{
dragok = false;
document.onmousemove = null;
}
document.onmousedown = down;
document.onmouseup = up;
}
)();
}
}