<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">//這個一定要加 因為ie8 xhtml4.0不支援fixed 如果第一個層高度超過瀏覽器高度 也就是有捲軸 imgdiv是不隨捲軸滾動而滾動,它一直都在那裡<body id="gn" ></body><script language="javascript"> function $$(titleName) { return document.createElement(titleName); }function $(e){ return document.getElementById(e);}var lodingBox = $$("div");lodingBox.style.position="fixed";lodingBox.style.width=screen.width+"px"; lodingBox.style.height=screen.height+"px"; lodingBox.style.backgroundColor="#cccccc"; lodingBox.id="lodingBox";var imgdiv=$$("div");var imgdiv_width="300";var imgdiv_height="100";var imfdiv_left=screen.width-screen.width/2-imgdiv_width/2;//為什麼要減去100px//我也不知道為什麼 因為這樣算出來上邊高底下低所以我就再減去100pxvar imfdiv_height=screen.height-screen.height/2-imgdiv_height/2-100;imgdiv.style.position="fixed";imgdiv.style.left=imfdiv_left+"px";imgdiv.style.top=imfdiv_height+"px";imgdiv.style.width=imgdiv_width+"px";imgdiv.style.height=imgdiv_height+"px"; imgdiv.style.backgroundColor="red"; imgdiv.id="imgdiv"; var lodingImg=$$("img"); lodingImg.src="loadingmin.gif"; var lodingText=$$("span"); lodingText.innerHTML="正在存入資料,請稍候...."; imgdiv.appendChild(lodingImg); imgdiv.appendChild(lodingText); $("gn").appendChild(lodingBox); $("gn").appendChild(imgdiv); var temp=1; zheli(10); // $("lodingBox").style.display="none"; //$("imgdiv").style.display="none";function zheli(n){if(n==1){return temp;}temp=temp*n;//document.write(temp+"<br />");//遞迴zheli(n-1);}</script>