Display div after a certain time, with setTimeout

Asked

Viewed 3,299 times

3

I’m trying to put setTimeOut in a div in javascript, but I’m not getting at all!

My code :

<script language="JavaScript" type="text/javascript">
 if(document.all){}
else document.captureEvents(Event.MOUSEMOVE);document.onmousemove=mouse;function mouse(e)
{if(navigator.appName=='Netscape'){xcurs=e.pageX;ycurs=e.pageY;}else{xcurs=event.clientX;ycurs=event.clientY;}
document.getElementById('mime').style.left=(xcurs-230)+'px';document.getElementById('mime').style.top=(ycurs-150)+'px';}
</script>

</head>
<div id="mime">
<iframe style="border:none; overflow:hidden; width:605px; height:250px;

float:left;" frameborder="0" scrolling="No" src="http://migre.me/qaksC"></iframe>
</div>

I’m wanting it to show up after a while, and the only Function I think it serves for is the setTimeOut, I have tried in many ways but no results, I tried so :

setTimeout('document.getElementById('mime')', 60000);

document.getElementById('mime').setTimeout(60000);

<script language="JavaScript" type="text/javascript">
 if(document.all){}
else document.captureEvents(Event.MOUSEMOVE);document.onmousemove=mouse;function mouse(e)
{if(navigator.appName=='Netscape'){xcurs=e.pageX;ycurs=e.pageY;}else{xcurs=event.clientX;ycurs=event.clientY;}
document.getElementById('mime').style.left=(xcurs-230)+'px';document.getElementById('mime').style.top=(ycurs-150)+'px';}
</script>
<script>
setTimeout(function(){
    document.getElementById('mime');
}, 60000);
</script>

1 answer

5


<div id="mime">
    <iframe style="border:none; overflow:hidden; width:605px; height:250px; float:left;" frameborder="0" scrolling="No" src="http://migre.me/qaksC"></iframe>
</div>

<script>
// O HTML da div precisa estar acima.
// Esconde a div no início
var div = document.getElementById('mime');
div.style.display = 'none';

// Mostra a div após 1 minuto
setTimeout(function() {
    div.style.display = 'block';
}, 60000);
</script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.