Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2780929
  • 博文数量: 77
  • 博客积分: 10204
  • 博客等级: 上将
  • 技术积分: 5035
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-05 22:13
文章分类
文章存档

2013年(1)

2010年(1)

2009年(17)

2008年(58)

我的朋友

分类:

2008-04-09 16:58:23

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Test</title>
        <style>
            *{
             margin:0;
             padding:0;
            }
            
            #dialog{
             position:absolute;
             left:50%;
             top:50%;
             width:300px;
             height:100px;
             line-height:100px;
             margin:-50px 0 0 -150px;
             text-align:center;
             background:#ffffff;
             border:1px #000 solid;
             z-index:999;
             font-size: 12px;
            }
            #shadow{
                position:absolute;
                left:0;
                top:0;
                width:100%;
                height:100%;
                background:#cccccc;
                z-index:100;
                filter:alpha(opacity=80);
                opacity:0.8;
            }
        </style>
        <script type="text/javascript">
            function $(id) {
                return document.getElementById(id);
            }
            function showDialog(info) {
                var shadow = document.createElement("div");            
                var dialog = document.createElement("div");
                                
                shadow.setAttribute("id", "shadow");        
                dialog.setAttribute("id", "dialog");
                
                // Create button
                var button = document.createElement("input");
                button.setAttribute("id", "bt");
                button.setAttribute("type", "button");
                button.setAttribute("value", "关闭");
                // Create dialog text
                var dialogText = document.createTextNode(info);
                dialog.appendChild(dialogText);
                dialog.appendChild(button);
                
                var container = $("container");
                
                container.appendChild(shadow);
                container.appendChild(dialog);
                
            }
            function hideDialog() {
                var container = $("container");
                var shadow = $("shadow");
                var dialog = $("dialog");
                container.removeChild(shadow);
                container.removeChild(dialog);
            }
            window.onload = function() {
                var bt = $("callWinBt");
                bt.onclick = function() {
                    showDialog("测试一下!");
                    var bt2 = $("bt");
                    bt2.onclick = function() {
                        hideDialog();
                    }
                };
            }
        </script>
    </head>
    <body>
        <div id="container">
            <input type="button" value="call window" id="callWinBt">
            <img src="1.jpg" width="150" height=200 align="center">
            <div>
                文本文本文本文本文本文本文本文本文本文本文本文本文本文本
            </div>
        </div>
    </body>
</html>

阅读(2361) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~