How do I set a timer for a image to appear in javascript or html?

3.9k views Asked by At

Currently I have the following piece of code but it isn't working on my facebook iframe application.

function Timer(){
    document.getElementById('buybtn').style.visibility = "visible"; 
    setTimeout(Timer,1080000);
}

and the following html:

<p style="text-align: center;">'</p>
<div id="buybtn">
   <p style="text-align:center">
      <a href="http://www.google.com" target="_blank">
         <img src="http://www.adspecialist.be/wp-content/themes/adspecialist/img/visit-my-website-en.png" border="0" />
       </a>
   </p>
</div>

Could you please let me know how to fix this problem

1

There are 1 answers

1
Christoph On BEST ANSWER

Your code is not supposed to work, because Timer() will never be called since you have your timeout inside the function. Move it outside and it will work.

function Timer(){
    document.getElementById('buybtn').style.visibility = "visible"; 
}

setTimeout(Timer,3000);

demo jsfiddle