javascript弹出提示框
2017-02-09 23:28
225 查看
先创建一个bodybg将整个页面覆盖,接着创建div将其绝对定位与页面
/** * * @param tip 显示的消息 * @param flag 是否刷新 true or false */ function tipdialog(tip,flag){ //获取页面高和宽 var iWidth=document.documentElement.clientWidth; var iHeight=document.documentElement.clientHeight; var height=Math.max(document.body.clientHeight, iHeight); var top=(parseInt(height)-300)/2; var left=(parseInt(iWidth)-300)/2; //创建覆盖页面的div var bodybg=document.createElement("div"); bodybg.id="bodybg"; bodybg.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:101;"; document.body.appendChild(bodybg); bodybg.onclick=function(){ if(flag){ location.reload(); } //关闭 document.getElementById("dialogbg").style.display="none"; //$("#dialogbg").fadeOut(); document.body.removeChild(bodybg); document.body.removeChild(dialogbg); }; //创建弹出框div var dialogbg=document.createElement("div"); dialogbg.id="dialogbg"; dialogbg.style.cssText="width:300px;height:150px;position: absolute;overflow: hidden;z-index: 102;" + "background-color: white;color:red;border-radius:3px;box-shadow: 0px 0px 10px rgba(0,0,0,.35);display: none;"; dialogbg.style.top=top+"px"; dialogbg.style.left=left+"px"; var titlebg=document.createElement("div"); titlebg.style.cssText="width:300px;color:black;height: 30px;background-color: #93e0e6;text-align: center; line-height:30px;"; titlebg.innerHTML="提示信息"; var tipbg=document.createElement("div"); tipbg.style.cssText="width: 300px;height: 120px;text-align: center;line-height: 120px;"; tipbg.innerHTML=tip; document.body.appendChild(dialogbg); dialogbg.appendChild(titlebg); dialogbg.appendChild(tipbg); //显示 document.getElementById("dialogbg").style.display="block"; //$("#dialogbg").fadeIn(); }
相关文章推荐
- 用javascript来判断浏览器是否禁止了弹出窗口,并在网页中以友好的方式来提示网站浏览者
- [javascript]解决IE7的window.close()弹出确认提示框
- javaScript关闭浏览器 (不弹出提示框)
- js javascript 表单tips效果,文本框弹出提示框效果(不带箭头效果与代码)
- js javascript 表单tips效果,文本框弹出提示框效果(带箭头效果与代码)
- javascript 关闭窗口时不弹出提示
- [javascript]解决IE7的window.close()不弹出确认提示框
- javaScript 关闭浏览器 (不弹出提示框)
- javascript关闭窗口,不弹出提示框
- [javascript]解决IE7的window.close()弹出确认提示框(转)
- javascript 弹出类似QQ或MSN的消息提示
- 一个关闭窗口不弹出提示的javascript代码
- 后台弹出javascript提示信息两方法小知识
- javaScript关闭浏览器 (不弹出提示框)
- javascript实现打开新窗口全屏,并且关掉父窗体(不弹出关闭提示)
- ASP.NET中使用javascript弹出提示信息
- javascript弹出消息提示框
- javascript关闭窗口不弹出提示对话框!
- JavaScript 强行弹出窗口 与 无提示关闭页面
- JavaScript js弹出确认消息框判断是否删除,删除前提示用户是否删除,点是删除,点否返回