How do I set a timer for a image to appear in java

2020-05-01 10:01发布

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条回答
别忘想泡老子
2楼-- · 2020-05-01 10:39

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

查看更多
登录 后发表回答