问题
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:
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
来源:https://stackoverflow.com/questions/20476440/how-do-i-set-a-timer-for-a-image-to-appear-in-javascript-or-html