這裏開我試圖做圖像滑塊兩個圖像,但是當我打開同一個頁面中的兩個標籤,或者如果我儘量減少Firefox和最大化再次圖像滑塊閃爍並且工作不正常。隱藏和顯示類使用setTimeout方法,它們放置在也使用setTimeout方法的淡入淡出類中。setTimeout的事件不工作屬性格式時相同的程序是在兩個不同的標籤
<html>
<head>
<style type="text/css">
.image1 {
height: 300;
left: 181px;
position: absolute;
top: 103px;
width: 300;
}
</style>
<script type="text/javascript">
var a = 1;
var flg = 0,
flg2 = 0;
function fade() {
setTimeout(function() {
if (flg2 == 0) {
hide();
flg2 = 1;
fade();
} else {
show();
flg2 = 0;
fade();
}
}, 3000);
}
function hide() {
document.getElementById("img1").style.opacity = a;
document.getElementById("img2").style.opacity = (1 - a);
if (a > 0)
a = a - 0.1;
else
flg = 1;
if (flg == 0)
setTimeout(function() {
hide();
}, 50);
else
flg = 0;
}
function show() {
document.getElementById("img1").style.opacity = a;
document.getElementById("img2").style.opacity = (1 - a);
if (a < 1.0)
a = a + 0.1;
else
flg = 1;
if (flg == 0)
setTimeout(function() {
show();
}, 50);
else
flg = 0;
}
</script>
</head>
<body onload="fade()">
<img class="image1" height="225" id="img1" src="img/image1.jpg" style="z-index:100" width="225"/>
<img class="image1" height="225" id="img2" src="img/image2.jpg" style="z-index:1" width="225"/>
</body>
</html>
當詢問你的代碼的幫助,請花時間來格式化你的代碼*可讀取*,使用適當的縮進和等。 –
我無法複製,請提供更多詳情?這是在某個版本的Firefox/OS上?我在Mac上使用Firefox 24。 – Mataniko