我使用Ajax爲我的網頁請求一些信息,並在Ajax運行時彈出一個「Please Wait」窗口。Javascript:Ajax和Show/Hide Div
這在Mozilla和Chrome中運行正常,但「請稍候」窗口不顯示在IE中。
這裏是我的代碼:
function openWaitMessage()
{
var wid = 300;
var hgt = 200;
var left = 0;
var top = 0;
var myWidth = 0, myHeight = 0;
if(typeof(window.innerWidth) == 'number') {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
var scrOfX = 0, scrOfY = 0;
if(typeof(window.pageYOffset) == 'number') {
//Netscape compliant
scrOfY = window.pageYOffset;
scrOfX = window.pageXOffset;
} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
//DOM compliant
scrOfY = document.body.scrollTop;
scrOfX = document.body.scrollLeft;
} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
//IE6 standards compliant mode
scrOfY = document.documentElement.scrollTop;
scrOfX = document.documentElement.scrollLeft;
}
left = scrOfX + (myWidth - wid)/2;
top = scrOfY + (myHeight - hgt)/2;
var div = document.getElementById("pleaseWait");
div.style.display = '';
div.style.visibility = 'visible';
div.style.left = left;
div.style.top = top;
} // openWaitMessage()
function getInformation {
openWaitMessage();
//////////////////////////////////////////////////////////////////////
// create a new ListRequest object and add the 'category' parameter //
//////////////////////////////////////////////////////////////////////
var listRequest = new ListRequest("lotatt-request");
/////////////////////////////////////
// create a new AjaxRequest object //
/////////////////////////////////////
var ajaxRequest = new AjaxRequest("/MyProject/services");
/////////////////////////////////////////
// send the list request to the server //
/////////////////////////////////////////
sendListRequest(ajaxRequest,listRequest,fillLotAtt,ajaxError);
}
HTML:
<div id="pleaseWait" style=" display: none; visibility: hidden; position:absolute; left:0px; top:0px; width:300px; height:200px; z-Index:999;">
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tr class="dialogHeaderCell" >
<td>
Please Wait...
</td>
</tr>
<tr>
<td align="center">
<img src="please_wait.gif" alt="Loading...Please wait.">
</td>
</tr>
</table>
</div>
<input type="button" name="DisplayInfo" class="secondary_button" value="Display Information " onClick="getInformation()"/>
請幫幫忙,謝謝你的設置提前left
和top
當編程
'// IE 4 compatible'好神,有必要嗎? – Chad 2012-02-27 03:08:56
也許它是屏幕外的?您是否使用IE開發工具檢查了div的左側屬性和頂端屬性? – bfavaretto 2012-02-27 03:32:05
我該怎麼做?你能指導我嗎?我已安裝IE開發工具,但不知道如何使用它 – Ianthe 2012-02-27 03:34:05