如何设置计时器以使图像显示在javascript或html中? [英] How do I set a timer for a image to appear in javascript or html?

查看:42
本文介绍了如何设置计时器以使图像显示在javascript或html中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我有以下代码,但无法在我的Facebook iframe应用程序上正常工作.

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);
}

和以下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

推荐答案

您的代码不起作用,因为 Timer()永远不会被调用,因为您的超时时间 inside 函数.将其移到外部即可使用.

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);

演示jsfiddle

这篇关于如何设置计时器以使图像显示在javascript或html中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆