js弹出公告

调用:

$(document).ready(function(){
sAlert("公告","内容");
}); 

方法

function sAlert(strTitle,strContent){

 var msgw,msgh,bordercolor;
 msgw=400;//提示窗口的宽度
 msgh=100;//提示窗口的高度
 titleheight=25 //提示窗口标题高度
 bordercolor="#336699";//提示窗口的边框颜色
 titlecolor="#99CCFF";//提示窗口的标题颜色
 var sWidth,sHeight;
 sWidth=document.body.offsetWidth;
 sHeight=screen.height;
 var bgObj=document.createElement("div");
 bgObj.setAttribute(‘id‘,‘bgDiv‘);
 bgObj.style.position="absolute";
 bgObj.style.top="0";
 bgObj.style.background="#777";
 bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
 bgObj.style.opacity="0.6";
 bgObj.style.left="0";
 bgObj.style.width=sWidth + "px";
 bgObj.style.height=sHeight + "px";
 bgObj.style.zIndex = "10000";
 document.body.appendChild(bgObj);

 var msgObj=document.createElement("div");
 msgObj.setAttribute("id","msgDiv");
 msgObj.setAttribute("align","center");
 msgObj.style.background="white";
 msgObj.style.border="1px solid " + bordercolor;
 msgObj.style.position = "absolute";
 msgObj.style.left = "50%";
 msgObj.style.top = "50%";
 msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
 msgObj.style.marginLeft = "-225px" ;
 msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
 msgObj.style.width = msgw + "px";
 msgObj.style.height =msgh + "px";
 msgObj.style.textAlign = "center";
 msgObj.style.lineHeight ="25px";
 msgObj.style.zIndex = "10001";

 var title=document.createElement("h4");
 title.setAttribute("id","msgTitle");
 title.setAttribute("align","right");
 title.style.margin="0";
 title.style.padding="3px";
 title.style.background=bordercolor;
 title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
 title.style.opacity="0.75";
 title.style.border="1px solid " + bordercolor;
 title.style.height="18px";
 title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
 title.style.color="white";
 title.style.cursor="pointer";
 title.title = "点击关闭";
 title.innerHTML="<table border=‘0‘ width=‘100%‘><tr><td align=‘left‘><b>"+ strTitle +"</b></td><td>关闭</td></tr></table></div>";
 title.onclick=function(){
 document.body.removeChild(bgObj);
 document.getElementById("msgDiv").removeChild(title);
 document.body.removeChild(msgObj);
 }
 document.body.appendChild(msgObj);
 document.getElementById("msgDiv").appendChild(title);
 var txt=document.createElement("p");
 txt.style.margin="1em 0";
 txt.setAttribute("id","msgTxt");
 txt.innerHTML=strContent;
 document.getElementById("msgDiv").appendChild(txt);
}
时间: 2024-12-19 15:48:05

js弹出公告的相关文章

JS弹出对话框的三种实现方式的意义

最近开始学习JavaScript,最开始讲的就是alert().confirm()和prompt()三种JS弹出对话框.三种弹出对话框分别是警告.确认和提示消息. 第一种警告消息框 (alert)     alert 方法有一个参数,即希望对用户显示的文本字符串.该字符串不是 HTML 格式.该消息框提供了一个"确定"按钮让用户关闭该消息框,并且该消息框是模式对话框,也就是说,用户必须先关闭该消息框然后才能继续进行操作. <script> alert("Hello

JS弹出浮层

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

[King.yue]Ext.JS 弹出窗体取值赋值

//从Grid取值var name = Ext.getCmp(gridGridID).getView().getSelectionModel().getSelection()[0].data.Name; var code = Ext.getCmp(gridGridID).getView().getSelectionModel().getSelection()[0].data.Code; //赋值ID Ext.getCmp('@V.ID_TXT_NAME').setValue(name);//不用

div+js 弹出层

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>jQuery弹出层效果</title> <style> .black_overlay{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background

Js弹出窗口代码,window.open方法

<html><script language=JavaScript> <!--function click() {if (event.button==2) {window.open('#','popwindows',"toolbar=no,menubar=no,width=200,height=200")}}document.onmousedown=click//--></script><head><meta http-

bootstrap中popover.js(弹出框)使用总结+案例

bootstrap中popover.js(弹出框)使用总结+案例 *bootstrap官方说明:http://v3.bootcss.com/javascript/#popovers 一. popover常用配置参数: 1 //常用配置参数: 2 $(document).ready(function() { 3 $('#temp').popover( 4 { 5 trigger:'click', //触发方式 6 template: '', //你自定义的模板 7 title:"标题",

一个JS弹出层用户登录效果

<html> <head> <meta http-equiv="Content-Type"content="text/html; charset=gb2312"/> <title>接触角测定仪 http://www.dgshengding.com</title> <style> body,#Mdown{margin: 0;padding: 0;text-align: center;font: n

js弹出提示框并跳转页面

1.提示框有两个选择项,点确定跳转,取消停留在原页面ScriptManager.RegisterStartupScript(Page, this.GetType(), "", "<script>if(confirm('请登录?')){location.href='login.aspx'};</script>", false); 2.提示框只有一个确定按钮,跳转到指定页面ScriptManager.RegisterStartupScript(p

Js弹出层,弹出框代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ