function createDiv()
{
if(document.body!=null)
{
var div_show_d=document.getElementById('div_show_d');
if(div_show_d==null||div_show_d==undefined)
{
div_show_d=document.createElement("");
document.body.appendChild(div_show_d);
//創建Marquee
CreateMarquee(div_show_d);
div_show_d.style.display="none";
}
}
}
function createFrame()
{
if(document.body!=null)
{
var frame_test=document.getElementById('frame_test');
if(frame_test==null||frame_test==undefined)
{
frame_test=document.createElement("");
document.body.appendChild(frame_test);
//創建Marquee
frame_test.style.display="none";
}
}
}
function showDiv()
{
var div=document.getElementById('div_show_d');
if(div!=null||div!=undefined)
{
div.style.height="100%";
div.style.width="100%";
div.style.position = "absolute";
div.style.top = "0px";
div.style.left = "0px";
div.style.zIndex = 999 ;
div.style.display="block";
CreateMarquee(div);
}
}
function showFrame()
{
var frame=document.getElementById('frame_test');
if(frame!=null||frame!=undefined)
{
frame.style.height="100%";
frame.style.width="100%";
frame.style.position = "absolute";
frame.style.top = "0px";
frame.style.left = "0px";
frame.style.zIndex = 998 ;
frame.style.display="block";
}
}
function HideDiv()
{
var div=document.getElementById('div_show_d');
if(div!=null||div!=undefined)
{
document.body.removeChild(div);
}
}
function HideFrame()
{
var frame=document.getElementById('frame_test');
if(frame!=null||frame!=undefined)
{
document.body.removeChild(frame);
}
}
function displayWaiting()
{
if(document.readyState=="loading")
{
createDiv();
createFrame();
showDiv();
showFrame();
}
}
function CreateMarquee(obj)
{
var mySpan=document.createElement("marquee");
mySpan.innerText="Loading......" ;//顯示于頁面的提示文字
mySpan.style.position="absolute";
mySpan.style.top="50%";
mySpan.style.width='100%';
mySpan.style.left="0px";
//mySpan.style.backgroundColor="#C3DAF5";//文字的背景顏色
mySpan.style.color="blue";//文件的字體顏色
mySpan.scrollDelay="100";
obj.appendChild(mySpan);
}
window.onload=function()
{
document.body.style.width="100%";
document.body.style.height="100%";
HideDiv();
HideFrame();
}
document.body.onclick=function()
{
var obj=window.event.srcElement;
if(obj!=undefined)
{
if(document.readyState!="loading")
{
setTimeout("displayWaiting()",300);
}
}
}
document.onreadystatechange=function()
{
if(document.body!=null)
{
_state=document.readyState;
if(_state=="complete")
{
HideDiv();
HideFrame();
}
}
}
使用说明:
将该JS添加到HTML页面中的Body标签后即可。注意页面命名中不能出现JS中的ID号。