[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

Javascript code to make image disapear after a a given period of time

I need a code that will either hide a div or an image after a period of time that i will set probably one second or faster if possible.  basically i just want to flash a picture and then have it dissapear.
0
hibridassassin
Asked:
hibridassassin
  • 3
  • 2
  • 2
  • +1
1 Solution
 
quincydudeCommented:
something like setting a timeout and on time out  set the style of the div to hidden
<script language="javascript">
  window.setTimeout("getElementById('xDiv').style.visibility='hidden';", 5000);
</script>

Open in new window

0
 
hibridassassinAuthor Commented:
so is xVid the name of the div?
0
 
hibridassassinAuthor Commented:
also, is 5000 seconds?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
quincydudeCommented:
it should be the id of div, replace it with your own div id and add this to your div by
<div id="mydiv"/> or something like that
0
 
quincydudeCommented:
5000 means 5 seconds
0
 
Michel PlungjanIT ExpertCommented:
and please use
document.getElementById for compatibility reasons
0
 
ZvonkoSystems architectCommented:
For compatibility reasons I would use this one:
<img name="EE" onLoad="setTimeout('document.images.EE.style.display=\'none\';',5000)" src="http://images.experts-exchange.com/images/eeWatermark.png"  >

Open in new window

0
 
Michel PlungjanIT ExpertCommented:
Yeah - that would work too, however I think.style is much younger and compatible from getElementById (at least on non-IE)
document.images['EE']

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now