Forum Moderators: open

Message Too Old, No Replies

Show/hide layer on load

         

Gondolf

9:18 am on Aug 25, 2006 (gmt 0)

10+ Year Member



I need to show a layer on page load, and make it hide after 5 seconds.

Any help much apreciated.

Thankyou.

Gondolf
Copenhagen
Denamrk

MisYu

11:49 am on Aug 25, 2006 (gmt 0)

10+ Year Member



JS:
document.onload = showLayer;

function showLayer() {
document.getElementById("myLayersId").style.display = "block";
window.setTimeout("hideLayer()", 5000);
}

function hideLayer() {
document.getElementById("myLayersId").style.display = "none";
}

HTML:
<div id="myLayersId">...</div>

CSS:
#myLayersId {
display: none;
}

Gondolf

3:44 pm on Aug 25, 2006 (gmt 0)

10+ Year Member



Can't make it work.

Maybe a stupid question but is the js kode for the head or body?

birdbrain

4:57 pm on Aug 25, 2006 (gmt 0)



Hi there Gondolf,

try it like this...


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
#hide {
width:400px;
border:3px double #000;
padding:20px;
margin:30px auto;
text-align:justify;
}
-->
</style>

<script type="text/javascript">
<!--
window.onload=function() {
setTimeout('document.getElementById("hide").style.display="none"',5000);
return;
}
//-->
</script>

</head>
<body>

<div id="hide">

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin massa. Nam vehicula.
Morbi velit nisi, mollis id, ultrices luctus, adipiscing sit amet, lectus. Nunc rhoncus
nisl ac enim. Maecenas vestibulum dolor ut velit. Maecenas condimentum pulvinar purus.
Pellentesque ac ipsum. Curabitur sodales, elit vel molestie hendrerit, elit odio rhoncus tellus,
nec gravida enim urna id velit. Donec nec tellus. Vestibulum nulla. Curabitur enim arcu,
ornare id, placerat eget, nonummy vitae, mauris. Nulla rutrum semper odio. Duis vulputate
ornare mauris. Praesent eget nibh sed ante ultricies scelerisque. Duis eget felis ut arcu porta
bibendum. Mauris rutrum. Vivamus consectetuer purus sit amet mi. Suspendisse eu augue.
Quisque nec enim. Nullam elementum. Quisque rhoncus. Ut cursus, pede sit amet facilisis pretium,
est erat congue tortor, eget tincidunt metus augue in mauris. Sed id pede. Nam varius faucibus massa.
In orci. Suspendisse metus nunc, egestas non, porta a, fermentum interdum, mi. Nulla vel tellus nec
erat consectetuer molestie. Vivamus turpis erat, rhoncus sed, ornare vel, volutpat sagittis, nibh.

</div>

</body>
</html>

birdbrain

Gondolf

1:10 pm on Aug 28, 2006 (gmt 0)

10+ Year Member



Thank you very much!

Gondolf

birdbrain

3:03 pm on Aug 28, 2006 (gmt 0)



No problem, you're welcome. ;)