我想显示加载图像,直到加载响应页面。
在这里我提交表单,servlet 将处理请求并需要大约 2 次来发送响应。到那时我想显示类似于下面的图像。
如果我使用 onbeforeunload 事件,则图像被挂起并且没有动画。但出于检查目的,使用了 onload 并按预期工作。
请帮助我...谢谢。
示例代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Servlet</TITLE>
<script type="text/javascript">
function showBackgroundDiv() {
var obj = document.getElementById("docBackground");
if (obj != null && obj != undefined) {
hideFormDiv();
obj.style.visibility = "visible";
resizeBackgroundDiv();
}
}
function hideFormDiv() {
var obj = document.getElementById("formDiv");
if (obj != null && obj != undefined) {
obj.style.visibility = "hidden";
}
}
function resizeBackgroundDiv() {
var obj = document.getElementById("docBackground");
if (obj != null && obj != undefined
&& obj.style.visibility == 'visible') {
var frameObj = document.getElementsByTagName("iframe")["TransFrame"];
if (frameObj != null && frameObj != undefined) {
frameObj.style.height = document.body.scrollHeight + "px";
frameObj.style.width = document.body.scrollWidth + "px";
}
obj.style.width = document.body.scrollWidth;
obj.style.height = document.body.scrollHeight;
}
}
</script>
</HEAD>
<BODY onbeforeunload="showBackgroundDiv()" onResize="resizeBackgroundDiv()">
<div id="formDiv">
<form action='hello' method='get'>
Name : <input type='text' name='name'>
<input type='submit' value='send'>
</form>
</div>
<div id="docBackground"
style="VISIBILITY: hidden; position: absolute; overflow: hidden; z-index: 100; top: 0px; left: 0px">
<iframe src="TransPage.html" style="height: 0px; width: 0px;"
frameborder="0" name="TransFrame" scrolling="no"> </iframe>
</div>
</BODY>
</HTML>