惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
I
InfoQ
B
Blog
WordPress大学
WordPress大学
Jina AI
Jina AI
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
Google Developers Blog
C
Check Point Blog
月光博客
月光博客
L
LangChain Blog
GbyAI
GbyAI

博客园 - 郭大侠

【原创】还有比我这更简单的静态树吗? - 郭大侠 - 博客园 asp.net获得路径的方法 用表格实现简单网站左侧导航 div里面套3个div,居中显示,兼容ie6-8,ff,咋就这么麻烦呢 网站设计之asp.net网站多语言版本 vs2005常用快捷键 Repeater显示父子表数据,无闪烁 jquery学习相关 show div and mouse can move on the div js map 送大家一首歌曲,《保卫延安》片尾曲 vs2005调试javascript url重写 总有人问js二级联动问题,给出我写的一个例子 - 郭大侠 - 博客园 oracle横表变竖表问题 中国房地产的实质 北京奥运会赛事电视直播表(绝对完整)--每天就抱着电视看吧! 动物为什么会预知地震,地震后为什么会下雨? 新工资税计算方法及年终奖个税算法
js+div+css 模拟弹出对话框
郭大侠 · 2009-06-11 · via 博客园 - 郭大侠

今天闲着,做了这么一个网页,在IE5.5-8,ff下测试通过,共享给大家.

<!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-Type" content="text/html; charset=utf-8"/>
<title>弹出模态对话框测试[IE6下测试通过]</title><style type="text/css">
    .hideDlg
    
{
        height
:129px;width:368px;
        display
:none;
    
}
    .showDlg
    
{
        background-color
:#ffffdd;
        border-width
:3px;
        border-style
:solid;
        height
:129px;width:368px;
        position
: absolute; 
        display
:block;
        z-index
:5;
    
}
    .showDeck 
{
        display
:block;
        top
:0px;
        left
:0px;
        margin
:0px;
        padding
:0px;
        width
:100%;
        height
:100%;
        position
:absolute;
        z-index
:3;
        background
:#cccccc;
    
}
    .hideDeck 
    
{
        display
:none;
    
}
</style><script type="text/javascript">
    
function showDlg()
    {
        
//显示遮盖的层
        var objDeck = document.getElementById("deck");
        
if(!objDeck)
        {
            objDeck 
= document.createElement("div");
            objDeck.id
="deck";
            document.body.appendChild(objDeck);
        }
        objDeck.className
="showDeck";
        objDeck.style.filter
="alpha(opacity=50)";
        objDeck.style.opacity
=40/100;
        objDeck.style.MozOpacity=40/100;
        //显示遮盖的层end
        
        
//禁用select
        hideOrShowSelect(true);
        
        
//改变样式
        document.getElementById('divBox').className='showDlg';
        
        
//调整位置至居中
        adjustLocation();
        
    }
    
    
function cancel()
    {
        document.getElementById(
'divBox').className='hideDlg';
        document.getElementById(
"deck").className="hideDeck";
        hideOrShowSelect(
false);
    }
    
    
function hideOrShowSelect(v)
    {
        
var allselect = document.getElementsByTagName("select");
        
for (var i=0; i<allselect.length; i++)
        {
            
//allselect[i].style.visibility = (v==true)?"hidden":"visible";
            allselect[i].disabled =(v==true)?"disabled":"";
        }
    }
    
    
function adjustLocation()
    {
        
var obox=document.getElementById('divBox');
        
if (obox !=null && obox.style.display !="none")
        {
            
var w=368;
            
var h=129;
            
var oLeft,oTop;
            
            
if (window.innerWidth)
            {
                oLeft
=window.pageXOffset+(window.innerWidth-w)/2 +"px";
                oTop=window.pageYOffset+(window.innerHeight-h)/2 +"px";
            }
            
else
            {
                
var dde=document.documentElement;
                oLeft
=dde.scrollLeft+(dde.offsetWidth-w)/2 +"px";
                oTop=dde.scrollTop+(dde.offsetHeight-h)/2 +"px";
            }
            
            obox.style.left
=oLeft;
            obox.style.top
=oTop;
        }
    }
    
</script></head><body onresize="adjustLocation();">
    
<input type="button" value="click me" onclick="showDlg();" size="10px" /><br/>
    
<input type="text" value="" size="10px" /><href="http://www.baidu.com" target="_blank">百度</a><br/>
    
<select>
        
<option selected="selected">1</option>
        
<option>2</option>
    
</select><br/>
    
    
<div id="divBox" class="hideDlg" style="" >
            
<table width="100%" style="height:100%; width: 100%;" id="table1">
                    
<tr>
                        
<td style="height: 20px; text-align: center;" colspan="3">请输入用户名及密码</td>
                    
</tr>
                    
<tr>
                        
<td>用户名</td>
                        
<td>
                            
<input name="TextBox1" type="text" id="TextBox1" />
                        
</td>
                        
<td></td>
                    
</tr>
                    
<tr>
                        
<td>密码</td>
                        
<td>
                            
<input name="TextBox2" type="text" id="TextBox2" /></td>
                        
<td></td>
                    
</tr>
                    
<tr>
                        
<td></td>
                        
<td>
                            
<input type="button" name="Button1" value="Login" id="Button1" size="10" onclick="alert(TextBox1.value)"/>&nbsp;&nbsp;
                            
<input type="button" name="Button2" value="Cancel" id="Button2" size="10" onclick="cancel();" />
                            
</td>
                        
<td>&nbsp;</td>
                    
</tr>
            
</table>
    
</div></body>
</html>