Udskift billed
Jeg har problemer med at få denne kode til at virke.Billedet køre godt nok frm og tilbage men billedet udskiftes ikke.
hvad går der galt?
<script LANGUAGE="JavaScript1.2">
<!-- Begin
var speed = 1;
var stage = "DriveTo";
var Bil_Pic = "Billeder/bil_right.gif";
var ie4up = (document.all) ? 1 : 0;
var i, doc_width = 800, doc_height = 600;
if (ie4up)
{
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
document.write("<div id=\"bil\" style=\"POSITION: ");
document.write("absolute; Z-INDEX: 0; VISIBILITY: ");
document.write("visible; BOTTOM: 0px; LEFT: 0px;\"><img src=\"");
document.write(Bil_Pic + "\" border=\"0\"></div>");
}
function StartAni()
{
// ==== KØR FREM ==============================================================================
if (stage == "DriveTo")
{
if (document.all["bil"].style.pixelLeft > doc_width - 150)
{
document.all["bil"].src = "Billeder/bil_left.gif";
stage = "DriveBack"
}
document.all["bil"].style.pixelLeft = document.all["bil"].style.pixelLeft + 2;
}
// ============================================================================================
// ==== KØR TILBAGE ===========================================================================
if (stage == "DriveBack")
{
if (document.all["bil"].style.pixelLeft == 0)
{
stage = "DriveTo"
}
document.all["bil"].style.pixelLeft = document.all["bil"].style.pixelLeft - 2;
}
// ============================================================================================
setTimeout("StartAni()", speed);
}
if (ie4up)
{
setTimeout("StartAni()", 5000);
}
// End -->
</script>