In jedem von mir getesteten Browser funktioniert dieses Script, nur leider im Firefox nicht.
Ich kann den Fehler nach langer Suche leider nicht finden, bitte helft mir! Kopiert einfach kurz den Code in eine lokale .html Datei und öffnet diese mal kurz. Danke schonmal.
Code:
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
var thePos=dimx=Dimx=x=0,time,openlayer;
var zwischenspeicher = new Array();
zwischenspeicher[0] = new Object();
zwischenspeicher[0]["Name"] = "init";
zwischenspeicher[0]["Wert"] = "1";
function debug()
{
for (var i = 0; i < zwischenspeicher.length; i++) {
document.write("<dl><dt>zwischenspeicher " + (i + 1) + "<\/dt>");
for (var Eigenschaft in zwischenspeicher[i])
document.write("<dd>" + Eigenschaft + ": " + zwischenspeicher[i][Eigenschaft] + "<\/dd>");
document.write("<\/dl>");
}
}
function pos(layerid,pos)
{
var gefunden = 0;
if(openlayer!=layerid)
{
//Check ob vorhanden
var erledigt = 0;
for (var i = 0; i < zwischenspeicher.length; i++)
{
for (var Eigenschaft in zwischenspeicher[i])
{
if(zwischenspeicher[i]["Name"]==layerid)
{
if(erledigt==0)
{
//alert("Bekannt - "+zwischenspeicher[i]["Name"]+" - "+zwischenspeicher[i]["Wert"]+" / Schreibe: "+pos);
gefunden = 2;
Dimx = parseInt(zwischenspeicher[i]["Wert"]);
zwischenspeicher[i]["Wert"] = pos;
erledigt = 1;
}
}
}
}
//Neuanlage
if(gefunden==0)
{
x = zwischenspeicher.length;
zwischenspeicher[x] = new Object();
zwischenspeicher[x]["Name"] = layerid;
zwischenspeicher[x]["Wert"] = pos;
//alert("Neuanlage - "+zwischenspeicher[x]["Name"]+" - "+zwischenspeicher[x]["Wert"]);
Dimx = 0;
}
}
openlayer = layerid;
thePos = pos-(pos*2);
browser = navigator.appName;
usAgent = navigator.userAgent;
if (browser == "Microsoft Internet Explorer" || usAgent.indexOf("Opera") >- 1)
{
clearTimeout(time);
}
dmx();
}
function dmx()
{
time = setTimeout("dmx()",0);
dimx = Math.round(Dimx+=((thePos)-Dimx)*4/20);
if (document.getElementById)
{
document.getElementById(openlayer).style.left = dimx;
}
else if (document.all)
{
document.all[openlayer].style.left = dimx;
}
if (thePos == dimx)
{
//Hier der Fehler????, Einfach mal die Auskommentiertung vor
//alert weglassen und im Firefox und Internet Explorer anschauen.
//Aber achtung, Firefox schmiert dann ab
//alert("Werte:\n\nthePos: "+thePos+" \ndimx: "+dimx);
time = clearTimeout(time);
}
}
</script>
<style type="text/css">
<!--
.scrolleroutside {
border: 1px solid #BBBBBB;
margin-top: 10px;
width: 250px;
overflow: hidden;
position: absolute;
}
.scrollerinside {
position:relative;
}
-->
</style>
</head>
<body>
<a href='javascript:debug();' onfocus='this.blur()'>Debug</a><br><br>
<!-- Ebene 1 -->
<div class="scrolleroutside">
<table cellspacing="0" cellpadding="0" id="ebene1" class="scrollerinside"><tr>
<td width="250" height="200"><img name="Bild1" src="" width="250" height="200" alt="Bild1" style="background-color: #FF0000"></td>
<td width="250" height="200"><img name="Bild2" src="" width="250" height="200" alt="Bild2" style="background-color: #00FF00"></td>
<td width="250" height="200"><img name="Bild3" src="" width="250" height="200" alt="Bild3" style="background-color: #0000FF"></td>
<td width="250" height="200"><img name="Bild4" src="" width="250" height="200" alt="Bild4" style="background-color: #FFFF00"></td>
</tr></table>
</div>
<p style="margin-top: 250px;">
<a href="javascript:pos('ebene1','0');" onfocus="this.blur()">Scroll nach 0</a><br>
<a href="javascript:pos('ebene1','250');" onfocus="this.blur()">Scroll nach 250</a><br>
<a href="javascript:pos('ebene1','500');" onfocus="this.blur()">Scroll nach 500</a><br>
<a href="javascript:pos('ebene1','750');" onfocus="this.blur()">Scroll nach 750</a><br>
</p>
<!-- Ebene 2 -->
<div class="scrolleroutside">
<table cellspacing="0" cellpadding="0" id="ebene2" class="scrollerinside"><tr>
<td width="250" height="200"><img name="Bild1" src="" width="250" height="200" alt="Bild1" style="background-color: #FF0000"></td>
<td width="250" height="200"><img name="Bild2" src="" width="250" height="200" alt="Bild2" style="background-color: #00FF00"></td>
<td width="250" height="200"><img name="Bild3" src="" width="250" height="200" alt="Bild3" style="background-color: #0000FF"></td>
<td width="250" height="200"><img name="Bild4" src="" width="250" height="200" alt="Bild4" style="background-color: #FFFF00"></td>
</tr></table>
</div>
<p style="margin-top: 250px;">
<a href="javascript:pos('ebene2','0');" onfocus="this.blur()">Scroll nach 0</a><br>
<a href="javascript:pos('ebene2','250');" onfocus="this.blur()">Scroll nach 250</a><br>
<a href="javascript:pos('ebene2','500');" onfocus="this.blur()">Scroll nach 500</a><br>
<a href="javascript:pos('ebene2','750');" onfocus="this.blur()">Scroll nach 750</a><br>
</p>
</body>
</html>