Rome hotels - Watch Anime Online - Self Improvement Articles Directory - Funbrain - Online Advertising

PDA

View Full Version : On page popup/overlay


deadmoon
Feb 13th 2007, 10:04 am
Hi
What is the best way to display a div element when someone visits the page, but if they click "Close" it hides it? I want it like an overlay

thanks

ccoonen
Feb 13th 2007, 10:48 am
have an absolutly positioned (with css) div on top of everything with top:0px; left:0px; width:100%; height:100%; position:absolute; and give it an ID (id="overlay")

Then have your link or button call a javascript function document.getElementById("overlay").style.display = "none";

designcode
Feb 13th 2007, 12:34 pm
First make a div after body tag


<div id="overlayDiv" style="top:0px; left:0px; width:100%; height:100%; position:absolute;">
My contents here

<a href="#" onclick="toggleDiv('close')">Close</a>
</div>]


Now here is javascript function,

<script>
function toggleDiv(display)
{
obj = document.getElementById("overlayDiv");
if(display == "open")
obj.style.display == "block";
else if((display == "close")
obj.style.display == "none";
}
</script>


I have not tested it, but it should work fine. If not let me know.