tags:

views:

2195

answers:

2

want to know Simply the javascript to overlay a div on centre of the page.

Just want to use plain java script to show and hide a div on the center of the page with "Please wait..." message and disable the background. Also this div shoud show on top of the other content of the page.

My div looks like this <div id='mydiv' style="display:none;" ><img src="myimg.gif" /> Please Wait... </div>

On click of a button , I want to show the div content center aligned on the page.

I do not want to use jquery,extjs,,etc to achieve this.

I have seen a few examples on the web with lot of other features added to a modal popup, just looking for something simple and clean.The bare minimum JS required to do this.

+1  A: 

The div you want to display needs to have an ID:

<div id="loaderdiv">

Then in your javascript, you display this div with the following code:

document.getElementById("loaderdiv").style.display = '';

Thats the bare minimum you'll need.

Centering the image can be done using CSS:

<div style="position:absolute;top:50%;left:50%;margin-top:-[imgheight/2]px;margin-left:-[imgwidth/2]px">
bouke
Thanks bouke, I konw this part - but how do i center align it and show it on top of the screen is my real query.
dotnetcoder
+1  A: 
Ahmed Mozaly