我的代码应该显示广告10秒钟,然后加载嵌入代码。 它在Firefox上工作正常,但在IE9上,它在后台同时运行广告和嵌入代码。
<script type="text/javascript">
var nbsec = 10;
var c = 0;
var t;
var timer_is_on = 0;
var sum = 0;
function timedCount()
{
c = c + 1;
t = setTimeout("timedCount()", 1000);
sum = nbsec - c;
document.getElementById('chrono').innerHTML = "<br>Loading .. Please wait " + sum + "secondes";
if(c == nbsec) {
stopCount();
document.getElementById('mypub').style.visibility = 'hidden';
document.getElementById('mygame').style.visibility = 'visible';
document.getElementById('mygame').style.display = 'block';
document.getElementById('mygame').style.height = 'auto';
document.getElementById('mypub').style.height = '0px';
document.getElementById('mypub').style.padding = '0px';
document.getElementById('mypub').innerHTML = "";
}
}
function stopCount()
{
clearTimeout(t);
timer_is_on = 0;
}
</script>
<table border="2" align="center" color="F2FC7E">
<tr>
<td>
<div id="mypub" style="visibility: visible; text-align:center; padding:20px;">
<script>
..............
</script>
<div id="chrono" style="color:#FFF;"></div>
</div>
<div id="mygame" style="visibility: hidden;display:none; height:0px">
<param name="initial_focus" value="true">
<applet>
........................
</applet>
</div>
</td>
</tr>
</table>
<script type="text/javascript">
timedCount();
</script>
无论如何都有解决这个问题的方法吗?
答案 0 :(得分:1)
<script type="text/javascript">
var nbsec = 10;
function timedCount() {
document.getElementById('chrono').innerHTML = "<br>Loading .. Please wait " + nbsec + "secondes";
if( nbsec ){ // if sum != 0, wait call again
setTimeout( timedCount, 1000 );
nbsec--; // counter
} else { // do after 10 sec
document.getElementById('mygame').style.cssText = "visibility:visible;display:block;height:auto;";
document.getElementById('mypub').style.cssText="visibility:hidden;height:0px;padding:0px;";
document.getElementById('mypub').innerHTML = "";
}
}
// stopCount is not needed
// start counter
timedCount();
</script>
那是关于逻辑的