利用AJAX实现实现web页面的模态对话框

模态对话框是,当弹出对话框时后面的内容无法操作。本次利用ajax制作的模太对话框并不是浏览器提供的模太对话框,而是通过层和ajax技术实现的虚拟的模太对话框.

样式表,css代码:

ContractedBlock.gif ExpandedBlockStart.gif Code
.abc{    
      position
:absolute;    
      left
:1px;    
      top
:1px;    
      width
:1024px;    
      height
:768px;    
      z-index
:0;    
      background-repeat
: repeat;    
      background-color
:white;    
      FILTER
: alpha(opacity=60);     
      opacity
: 0.6;    
          
          
   
}    
       
   .start
{    
   
}    
       
   .abc1 
{    
      position
:absolute;    
      left
:350px;    
      top
:240px;    
      width
:300px;    
      height
:100px;    
      z-index
:0;    
   
}

 

脚本,javascript代码:

 


ContractedBlock.gif ExpandedBlockStart.gif Code
var xmlHttp;    
   
    
function createXMLHttpRequest() {    
            
if (window.ActiveXObject) {    
                xmlHttp 
= new ActiveXObject("Microsoft.XMLHTTP");    
            }     
        
else if (window.XMLHttpRequest) {    
            xmlHttp 
= new XMLHttpRequest();    
        }    
    }    
   
function forget(){    
   
    createXMLHttpRequest();    
        
    
var queryString = "tryAjaxAction.do?";    
    queryString 
= queryString + createString()    
      
+ "&timeStamp=" + new Date().getTime();    
    xmlHttp.onreadystatechange 
= doForget;    
    xmlHttp.open(
"GET""forget.jsp""true");    
    xmlHttp.send(
null);    
         
}    
   
function doForget(){    
    
if(xmlHttp.readyState == 4) {    
        
if(xmlHttp.status == 200) {    
         
var layer = document.getElementById("Layer1");    
         layer.className 
= "abc";    
         
var layer2 = document.getElementById("Layer2");    
         layer2.className 
= "abc1";    
         layer2.innerHTML 
= xmlHttp.responseText;    
        }     
   }    
}

 

 

页面内容,xml代码:

 

ContractedBlock.gif ExpandedBlockStart.gif Code
<table width="100%" height="587"  border="0">   
  
<tr>   
    
<td height="138" colspan="3">     
    
<div id="Layer1">   
         
    
</div>   
     <div id="Layer2">   
      
</div>   
    <td>   
  
<tr>   
  
<tr>   
    
<td width="10%" height="137"><div align="center"> </div></td>   
    
<td width="77%"><div class="img_border"><img class="img_border" src="web/images/first_bg.jpg" width="740" height="135" border=0></div></td>   
    
<td width="13%"> </td>   
  <tr>   
  
<tr>   
    
<td height="28"> </td>   
    <td height="28"><html:form method="POST" action="/tryAjaxAction">   
    
<input type="hidden" name="method" />   
    <div id="serverResponse">   
        
    
</div>     
        <div align="center">   
            
<SPAN class=col777777><bean:message key="userName"></bean:message></SPAN>   
            
<html:text name="loginForm" property="email"></html:text>   
            <SPAN class=col777777><bean:message key="password"></bean:message></SPAN>   
            
<html:password name="loginForm" property="password"></html:password>   
            <html:button property="button" value="提交" onclick="test()">html:button>   
                    
            
<a class="ab" href="#"><bean:message key="regist"></bean:message></a>|<a class="ab" onClick="forget()" href="#"><bean:message key="forgetPassword"></bean:message></a>   
             
       
</div>   
    </html:form>   
         
        
    
</td>   
    <td height="28"> </td>   
  </tr>   
  <tr>   
    
<td height="80" colspan="3"> </td>   
  </tr>   
  <tr>   
    
<td height="162" colspan="3"> </td>   
  </tr>        
</table>

 

 

转载于:https://www.cnblogs.com/291099657/archive/2009/01/19/1378613.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值