- /*
- wanMessageBox弹出框
- msg: 将要显示的信息,如果需要换行以 々 符号隔开
- rowHeight: 每行显示的高度,
- width:消息框的宽度
- */
- function wanMessageBox(msg, rowHeight, width){
- var pop = window.createPopup();
- var _msg = "";
- var arr = msg.split('々');
- var rowCount = arr.length+1;
- for(var i=0;i<arr.length;i++){
- if(_msg != "") _msg += "<br /> ";
- _msg += arr[i];
- }
- var w = width;
- var h = rowCount * rowHeight + 30;
- /*
- //居中显示
- var l = (document.body.clientWidth - w) / 2;
- var t = (document.body.clientHeight - h) / 2;
- */
- /*
- //显示在右下方
- */
- var l = document.body.scrollWidth - w - 1;
- var t = document.body.clientHeight - h - 1;
- var container = document.createElement("div");
- var items = document.createElement("div");
- items.style.cssText = "z-index:50001; background:#fff; top:" + t + "px; left:" + l + "px; width:" + w + "px; height:" + h + "px; border:4px double #99CCFF;font-size:14px; font-family:宋体;position:absolute;";
- items.onmousedown = mousedown;
- var title = document.createElement("div");
- title.style.cssText = "width:100%; height:26px; cursor:move; line-height:26px; padding-left:5px; background:#fff; border-bottom:1px solid #99CCFF;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#99CCFF, EndColorStr=#EEF7FF);";
- var title_left = document.createElement("div");
- title_left.style.cssText = "float:left;font-weight:bold; color: #113DAE;";
- title_left.innerText = "系统消息";
- var title_right = document.createElement("div");
- title_right.style.cssText = "float:right; font-family:Webdings; font-size:16px; color: white; text-align:center; width:40px; cursor: pointer;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#F0172D, EndColorStr=#ECF5FF);";
- title_right.onclick = _hide;
- title_right.innerText = "r";
- var message = document.createElement("div");
- message.style.cssText = "padding:10px;margin:0; line-height:130%; color:black;";
- message.innerHTML = " " + _msg;
- title.appendChild(title_left);
- title.appendChild(title_right);
- items.appendChild(title);
- items.appendChild(message);
- container.appendChild(items);
- var bgDiv = document.createElement("div");
- bgDiv.style.cssText = " Z-INDEX: 50000; FILTER: alpha(opacity=50); LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 100%; BACKGROUND-COLOR: #BCBCBC; moz-opacity: 0.5; opacity: 0.5";
- bgDiv.onmouseup = function(){return false;}
- bgDiv.onmousemove = function(){return false;}
- bgDiv.onmousedown = function(){return false;}
- bgDiv.onmousedown = function(){return false;}
- bgDiv.ondblclick = function(){return false;}
- bgDiv.onclick = function(){return false;}
- bgDiv.oncontextmenu = function(){return false;}
- bgDiv.onselectstart = function(){return false;}
- document.body.appendChild(container);
- document.body.appendChild(bgDiv);
- _setSelectDisplay("none");
- var x,y,dragObj;
- function mousedown(){
- var obj = event.srcElement.parentNode;
- dragObj = obj;
- dragObj.onmousemove = mousemove;
- dragObj.onmouseup = mouseup;
- dragObj.setCapture();
- oEvent = window.event ? window.event : event;
- x = oEvent.clientX;
- y = oEvent.clientY;
- };
- function mousemove(){
- oEvent = window.event ? window.event : event;
- var _top = oEvent.clientY - y + parseInt(dragObj.style.top);
- var _left = oEvent.clientX - x + parseInt(dragObj.style.left);
- if(_left < 1) _left = 1;
- if(_top < 1) _top = 1;
- var sw = document.body.scrollWidth - dragObj.offsetWidth - 1;
- var sh = document.body.clientHeight - dragObj.offsetHeight - 1;
- if(_left > sw) _left = sw;
- if(_top > sh) _top = sh;
- try{
- dragObj.style.top = _top + "px";
- dragObj.style.left = _left + "px";
- }
- catch(e){ }
- x = oEvent.clientX;
- y = oEvent.clientY
- };
- function mouseup(){
- dragObj.onmousemove = null;
- dragObj.onmouseup = null;
- dragObj.releaseCapture();
- dragObj = null;
- };
- function _hide(){
- container.style.display = "none";
- bgDiv.style.display = "none";
- _setSelectDisplay("");
- };
- function _setSelectDisplay(dis){
- var selects = document.getElementsByTagName("select");
- for(var i=0;i<selects.length;i++){
- selects[i].style.display = dis;
- }
- };
- }
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <HTML>
- <HEAD>
- <TITLE> New Document </TITLE>
- <META NAME="Generator" CONTENT="EditPlus">
- <META NAME="Author" CONTENT="">
- <META NAME="Keywords" CONTENT="">
- <META NAME="Description" CONTENT="">
- <script type="text/javascript" src="wanMessageBox.js"></script>
- <script type="text/javascript">
- function show(msg){
- var p = new wanMessageBox(msg, 22, 340);
- }
- </script>
- </HEAD>
- <BODY style="margin:0px; padding:0px;">
- <input type="button" onclick="show('北京奥运会北京奥运会北京奥运会北京奥运会々<font color=red><b>恭喜福建龙岩小姑娘夺得蹦床金牌</b></font>々北京奥运会北京奥运会北京奥运会北京奥运会々北京欢迎您!');" value="show">
- <select style="width:100px;"></select>
- </BODY>
- </HTML>