Forum Moderators: open

Message Too Old, No Replies

Need Javascript to reveal hidden <DIV> after X time

         

pkeetch

7:07 pm on Feb 4, 2009 (gmt 0)

10+ Year Member



Reposting in a new topic because the last was similar only and seemed to be closed.

I'm trying to use the show/hide capability to hide a div element for a specific period of time, and then reveal it.

I've tried all sorts of things from different places and nothing is working. Specifically, here is the one that I am attempting currently:

<script type='text/javascript'>

function MM_showHideLayers(element, time, action)
{
setTimeout("changeVisibility('" + element + "','" + action + "')", time)
}

function changeVisibility(element, action)
{
document.getElementById(element).style.visibility=action;
}

</script>

<div id="buy"><a href="#" target="_New"><img src="http://www.example.com/images/paul-sig.jpg" onload="MM_showHideLayers('buy', 5000, 'visible')"></a></div>

If anyone can help me with this, I would greatly appreciate it.

[edited by: tedster at 10:13 pm (utc) on Feb. 4, 2009]
[edit reason] switch to example.com [/edit]

RonPK

9:58 pm on Feb 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think the problem is that the image is not loaded when the initial visibility is set to hidden. So the onload event will simply not be triggered.

jetteroheller

6:53 am on Feb 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I think the problem is that the image is not loaded when the initial visibility is set to hidden. So the onload event will simply not be triggered.

Instead of hidden, style=top:-10000 can be used

Move to the right position when loaded