如下圖所示: 複製程式碼 程式碼如下: <br> function alertWin(title, msg, w, h) { <br><br> var titleheight = "22px"; // 窗口标题高度 <br> var bordercolor = "#666699"; //窗口的边框颜色 <br> var titlecolor = "#FFFFFF"; // 窗口的标题颜色 <br> var titlebgcolor = "#666699"; // 窗口的标题背景色 <br> var bgcolor = "#FFFFFF"; // 内容背景色 <br> var iWidth = document.documentElement.clientWidth; //这个窗口的宽度 <br> var iHeight = document.documentElement.clientHeight; //这个窗口的高度 <br><br> //背景层的格式 <br> var bgObj = document.createElement("div"); <br><br> bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:" + iWidth + "px;height:" + Math.max(document.body.clientHeight, iHeight) + "px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:1000;"; <br><br> document.body.appendChild(bgObj); <br><br> var iframe2 = document.createElement("iframe"); <br> iframe2.style.cssText = "position:absolute; top:0px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000; z-index:1001; border-style:none; border-width:0px; border:0px;width:" + iWidth + "px;height:" + iHeight + "px"; <br> bgObj.appendChild(iframe2); <br><br> //创建一个弹出层 <br> var msgObj = document.createElement("div"); <br> //设置弹出的层的样式 <br> msgObj.style.cssText = "position:absolute;font:11px '宋体';top:" + (iHeight - h) / 2 + "px;left:" + (iWidth - w) / 2 + "px;width:" + w + "px;height:" + h + "px;text-align:center;border:1px solid " + bordercolor + ";background-color:" + bgcolor + ";padding:1px;line-height:22px;z-index:1001;"; <br> document.body.appendChild(msgObj); <br> //创建一个table用于容纳层上的内容 <br> var table = document.createElement("table"); <br> //将Table放到弹出层上 <br> msgObj.appendChild(table); <br> //设置table的格式 <br> table.style.cssText = "margin:0px;border:0px;padding:0px;"; <br> table.cellSpacing = 0; <br> //插入一行用于显示标题 <br> var tr = table.insertRow(-1); <br> //插入一个单元格用于容纳标题 <br> var titleBar = tr.insertCell(-1); <br> titleBar.style.cssText = "width:100%;height:" + titleheight + "px;text-align:left;padding:3px;margin:0px;font:bold 13px '宋体';color:" + titlecolor + ";border:1px solid " + bordercolor + ";cursor:move;background-color:" + titlebgcolor; <br> titleBar.style.paddingLeft = "10px"; <br> //设置标题 <br> titleBar.innerHTML = title; <br> //设置曾德拖动事件 <br>var moveX = 0; <br> var moveY = 0; <br> 🎜> var moveable = false; <br> var docMouseMoveEvent = document.onmousemove; var docMouseUpEvent = document.onmouseup; <br> // 滑鼠點選標題<br> var evt = getEvent(); <br> 可移動= true; moveLeft = parseInt(msgObj.style.left); <br> > document.onmousemove = function() { <br> var evt = get事件(); <br> var y = moveTop evt. clientY - moveY; <br> if (x > 0 && (x w msgObj.style.left = x "px"; <br> }.top = y "px"; <br> } document.onmouseup = function() { <br> document.onmousemove = docMouseMoveEvent; <br> 🎜> 且可動= false; <br> moveX = 0; <br> moveY = 0; moveLeft = 0; <br> moveLeft = 0; <br> }; <br> } <br><br> 🎜> var closeBtn = tr.insertCell(-1); <br> closeBtn.style.css closeBtn.innerHTML = " <span style='font-size:15pt;color:" titlecolor ";'>×</span>"; <br> closeBtn removeChild(bgObj); <br> document.body.removeChild(msgObj); <br> <br><br> //彈出的訊息視窗內容為<br> var msgBox msgBox.style.cssText = "font:10pt '宋體'; "; <br> msgBox.colSpan = 2; <br> ) var nameBox = table.insertRow(-1); <br> var nameLable = nameBox.insertCell(-1); <br> nameLable.style.cssText = "font:12pt '宋體';text-align:center;" > :<br>"; <br> var nametext = nameBox.insertCell(-1); <br> nametext.style.cssText = "font:12pt '宋體';text-align:Left; margin-left:0px" ; <br> nametext.innerHTML = "<br><input type="text" value="" id="modalName"> var submitBox = table.insertRow(-1); <br> var Btn.style.cssText = "text-align:center;"; <br> submitBtn.colSpan = 2; <br> submitBtn.innerHTML = "<br><input type="Button" value="確定" id="saveHeader" onclick="return GetCark()"><o> > function getEvent() { <br> } <br> } <br> <br><br><input type="button" value="儲存表頭" onclick="alertWin('身分資訊收集','',300,150);"><br><br></o> </div>