http://jsfiddle.net/altafali/G2pLW/16/
如何修复它以便在ie或Opera浏览器中工作?
我还想在这个div的可见性上添加一些延迟?像30秒的计时器询问点击你的链接将在30秒内出现
在这里看到行动 http://www.symbianhome.com/ibibo-ibrowser-free-download-v2
感谢
答案 0 :(得分:0)
该代码适用于Opera。对于延迟演出,请使用此功能。单击后它也会禁用该按钮。
<script>
var remaining=30;
function countDown() {
remaining--; //decrease remaining
document.getElementById('counter').innerText = remaining; //update display
if (remaining > 0) { //more remains?
window.setTimeout(countDown, 1000); //yes. wait again
} else { //no. show the content
document.getElementById('divId').style.visibility = 'visible';
}
}
function delayShow(ele) {
ele.disabled = true;
document.getElementById('counter').innerText = remaining; //show it
window.setTimeout(countDown, 1000); //wait for 1 second then call countDown
}
</script>
<div id="divId" style="visibility:hidden">Content!</div>
<button onclick="delayShow(this)">DOWNLOAD</button> <span id="counter"></span>