CSS弹出背景半透明窗口
- <script type="text/javascript" src="<ww:url value=‘/js/jquery-1.8.3.min.js‘/>" language="javascript"></script>
- <script type="text/javascript">
- $(function(){
- var query = location.search;
- var equal_index = query.lastIndexOf("=");
- var result_index = query.indexOf("result");
- var submit_index = query.indexOf("submit");
- if(result_index != -1){
- if(query.substring(equal_index + 1) == ‘success‘) {
- $("#msg").text(‘保存成功‘);
- pupopen();
- }
- }
- if(submit_index != -1){
- if(query.substring(equal_index + 1) == ‘success‘) {
- $("#msg").text(‘上报成功‘);
- pupopen();
- }
- }
- });
- function pupopen(){
- $("#bg").css("display", "block");
- $("#popbox").css("display", "block");
- $(window).scroll(function(){ $(window).scrollTop(0); });// 禁止浏览器滚屏
- }
- function pupclose(){
- $("#bg").css("display", "none");
- $("#popbox").css("display", "none");
- $(window).unbind("scroll");// 恢复浏览器滚屏
- }
- </script>
- <style type="text/css">
- body{margin:0px;}
- #bg{width:100%;height:100%;top:0px;left:0px;position:absolute;filter: Alpha(opacity=50);opacity:0.5; background:#000000; display:none;}
- #popbox{position:absolute;width:300px; height:200px; left:50%; top:50%; margin:-200px 0 0 -200px; display:none; background:#FFFFFF;}
- </style>
- <body>
- 终于搞定这个效果了,IE和FF,OP均可以~
- 先说原理:两个层,一个高度和宽度都是100%,另一个就是你要弹出的窗口的具体内容,半透明在IE中是用filter: Alpha(opacity=60);在非IE中用opacity:0.60;
- </br>
- <div id="bg"></div>
- <div id="popbox"><center style="margin-top:70px;"><img src="<ww:url value=‘/image/correct.jpg‘/>" /> <span id="msg"></span></center>
- <br/><br/><br/>
- <img src="<ww:url value=‘/image/ok.png‘/>" width="70" height="35" onclick="pupclose()" style="cursor:pointer"/>
- </div>
- </body>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。