简体   繁体   English

如何设置图像的计时器以javascript或html显示?

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

Currently I have the following piece of code but it isn't working on my facebook iframe application. 目前我有以下代码,但它不适用于我的facebook iframe应用程序。

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

and the following html: 和以下的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 能告诉我如何解决这个问题吗?

Your code is not supposed to work, because Timer() will never be called since you have your timeout inside the function. 你的代码不应该工作,因为你的函数内部有超时,所以永远不会调用Timer() Move it outside and it will work. 将它移到外面它会起作用。

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

setTimeout(Timer,3000);

demo jsfiddle 演示jsfiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM