Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please wait...using javascript in jsp page

Status
Not open for further replies.

dangari

Programmer
Aug 5, 2009
9
0
0
KE
Hi all.I have been using a certain javascript code to display a "Please wait..." message on screen but it seems to work in some instances and not in others.Please assist me with javascript code that works in all instances. Below is the code I currently use.
In the head tags I have:
Code:
<script type="text/javascript">
 
<!-- Begin
function hideLoading() {
	document.getElementById('pageIsLoading').style.display = 'none'; // DOM3 (IE5, NS6) only
}
//  End -->
</script>
Right after the <body> tag I have:
Code:
<div id="pageIsLoading" style="position: absolute; display: block; padding-left: 50px; padding-right: 12px; width: auto; height: 65px; line-height: 40px; border: 1px solid #CCCCCC; color: #000000; font-weight: bold; font-family: verdana; font-size: 12px; background-color: #ffffff; background-image: url([URL unfurl="true"]http://localhost:8080/images/bannerz.jpg);[/URL] background-position: 100px center; background-repeat: no-repeat;">
	<script type="text/javascript">
	var window_width;
	var window_height;
	if( typeof( window.innerWidth ) == 'number' ) {
	  window_width = window.innerWidth;
	  window_height = window.innerHeight;
	} else if( document.documentElement &&( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	  window_width = document.documentElement.clientWidth;
	  window_height = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	  window_width = document.body.clientWidth;
	  window_height = document.body.clientHeight;
	}
	var left = Math.round((window_width - 240) / 2);
	var top = Math.round(((window_height - 130) / 3) + 30);
	document.getElementById('pageIsLoading').style.left = left+'px';
	document.getElementById('pageIsLoading').style.top = top+'px';
    </script><p><p><p><p>
    Loading page..Please wait...
</div>
Before </body> tag I have this:
Code:
<script type="text/javascript">
if (window.addEventListener) {
	window.addEventListener('load', hideLoading, false);
} else if (window.attachEvent)  {
	var r = window.attachEvent("onload", hideLoading);
} else  {
	hideLoading();
}
</script>
Please assist with making this work at all times or another solution that works on a single page without redirecting to another.
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top