要求:点击一个imagebutton在网页内弹出一个窗口,且能够移动和关闭,但不影响对原网页的操作,窗口关闭之前再点击按钮无效

解决方案 »

  1.   


    <!-- saved from url=file://C:/Documents and Settings/yfq/桌面/a.html -->
    <script>
    window.onerror = new Function("return(false);")
    </script><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML style="OVERFLOW-Y: auto; OVERFLOW-X: hidden; OVERFLOW: hidden"><HEAD>
    <STYLE>
     /* container */
     body {margin:0; padding:0; text-align:center; font-family:Verdana,"宋体"; font-size:12px; color:#333;}
     form,ul,ol,li,dl,dt,dd {margin:0; padding:0;}
     div{text-align:center; margin:0 auto; padding:0;}
     input{color:#333; font-size:12px; font-family:Arial;}
     ul,li{list-style:none;}
     img,a img {border-width:0;}
     /* opennav */
     .navigator_bg{position:absolute; width:100%; height:1000px; background-color:#234f74; filter:alpha(opacity=40); -moz-opacity:0.4;}
     #navigator, #xyeva{position:absolute; width:459px; height:281px; background-color:#fff; margin-left:-231px; padding:0px; z-index:99; top:100px; left:50%;}
     /*.tabborder {float:left; width:462px; height:285px;} */
     .tab {float:left; width:457px; height:279px; border: 1px solid #A5E3ED;} 
     .tabtitle{width:455px; height:28px; border:1px solid #FFF; background:url(http://www.cnblogs.com/images/cnblogs_com/amwggyy504/TabTitleBg.jpg) repeat-x left top; color:#0079BC; font-size:14px; line-height:28px;}
     .tabtitle img{float:right; margin:7px 10px 0 0;}
     .tabcontent{width:457px; height:248px; border-top:1px solid #A5E3ED; background:url(http://www.cnblogs.com/images/cnblogs_com/amwggyy504/TabContentBg.jpg) no-repeat left top;}
     .tabcontent ul{padding:20px 0; width:417px; margin-left:20px; *margin-left:0px; border-bottom:1px dotted #0079BC; text-align:left; line-height:20px; color:#0079BC;}
     .tabcontent li{padding:0 10px;}
     .tabcontent input{margin:0px 5px;}
     </STYLE>
    </HEAD><BODY><!--StartFragment--><A onclick=openEva(); href="#">弹出</A>
    <SCRIPT language=javascript>
     function openEva(){
     var nav = new Navigator();
     nav.createWin();
     }
     var preObjects = null;
     var Navigator = function(id){
             this.id = id;
     };
     Navigator.initIndex = 0;
     Navigator.CONTAINER = "navigator";
     Navigator.prototype.createWin = function(){
             Mark.showHintDiv();
             var html = "";
             var container = document.createElement("DIV");
             container.id = Navigator.CONTAINER;
             html += "<div class='tabborder'>"
             html += "        <div class='tab'>"
             html += "                <div class='tabtitle'><ul><li style='float:left; padding-left:183px;'><strong>弹出框</strong></li><li style='float:right; width:20px;'><a href='javascript:Mark.close();'><img src='TabTitleClose.jpg'></img></a></ul></div>"
             html += "                        <div class='tabcontent'>"
             html += "                                <ul><li>自定义显示的内容</li></ul>"
             html += "                                <ul><li>自定义显示的内容</li></ul>"
             html += "                        </div>"
             html += "                </div>"
             html += "</div>"
             container.innerHTML = html;
             document.body.appendChild(container);
     }
     /* 生成页面遮盖的方法 */
     function gernateDivBg(){
             var bg = document.createElement("DIV");
             document.documentElement.style.overflow = "hidden";
             with(bg.style){
                     position = "absolute";
                     top = "0px";
                     left = "0px";
                     width = document.documentElement.scrollWidth;
                     height = document.documentElement.scrollHeight;
             }
             return bg;
     };
     var Mark = new Object();
     Mark.showHintDiv = function(){
             var bg = gernateDivBg();
                     bg.id = Mark.id;
                     bg.className = "navigator_bg";
     
             document.body.appendChild(bg);
     }
     Mark.close = function(){
             if(document.getElementById(Mark.id)){
                     document.body.removeChild(document.getElementById(Mark.id));
             }        
             if(document.getElementById(Navigator.CONTAINER))
                     document.body.removeChild(document.getElementById(Navigator.CONTAINER));
             document.documentElement.style.overflowX= "hidden";
             document.documentElement.style.overflowY= "auto";
     };
     </SCRIPT>
     <!--EndFragment--></BODY>
    </HTML>
      

  2.   

    就是隐藏与显示一个DIV
    先弄个DIV,display设为none,点击后设置为block
      

  3.   

    大家能热心解答,我很感激
    但希望大家先看清我的要求
    1.imagebutton
    2.在网页内弹出窗口
    3.能够移动和关闭
    4.不影响对原网页的操作
    5.窗口关闭之前再点击按钮无效(不是遮盖层)
      

  4.   

    Ajax技术,上网搜索这方面知识,本人以前做过!
      

  5.   


    <html >
    <head>
    <title> New Document </title>
    <style type="text/css">
    .divShow
    {
    background-color:#D3E4F7;width:400px;height:200px;border:1px #000 solid;
    display:none;
    }
    .divShow .title
    {
    widht:100%;height:20px;border-bottom:1px solid #000;background-color:#0099CC;
    text-align:right;
    cursor:move;
    }
    </style>
    <script language="JavaScript" type="text/javascript">
    var drag_=false
    var D=new Function('obj','return document.getElementById(obj);')
    var oevent=new Function('e','if (!e) e = window.event;return e')
    function Move_obj(obj){
    var x,y;
    D(obj).onmousedown=function(e){
    drag_=true;
    with(this){
    style.position="absolute";var temp1=offsetLeft;var temp2=offsetTop;
    x=oevent(e).clientX;y=oevent(e).clientY;
    document.onmousemove=function(e){
    if(!drag_)return false;
    with(this){
    style.left=temp1+oevent(e).clientX-x+"px";
    style.top=temp2+oevent(e).clientY-y+"px";
    }
    }
    }
    document.onmouseup=new Function("drag_=false");
    }
    }
    function colseDiv(){
    document.getElementById("test").style.display="none";
    document.getElementById("btnShow").disabled="disabled";
    }
    function showDiv(){
    document.getElementById("test").style.display="inline";
    }
    </script>
    <body>
    <input type="button" onclick="showDiv()" value="Open" id="btnShow"/>
    <div id="test" class="divShow" >
    <div class="title" onmouseover='Move_obj("test")'>

    </div>
    <span onclick="colseDiv()" style="cursor:pointer">colse</span>
    </div>
    </body>
    </html>
      

  6.   

    看错了点 5.窗口关闭之前再点击按钮无效
    --将14楼的代码 脚本改下 function colseDiv(){
    document.getElementById("test").style.display="none";
    document.getElementById("btnShow").disabled="";
    }
    function showDiv(){
    document.getElementById("test").style.display="inline";
    document.getElementById("btnShow").disabled="disabled";
    }
      

  7.   

    点击ImageButton时 this.ImageButton1.Enabled = false; 然后弹出层   层的移动可用js控制,关闭层的时候 this.ImageButton1.Enabled = true;   不知可行否