Buon giorno,
mi occorrerebbe il vostro aiuto per risolvere un problema con lo scorrimento, tramite codice JavaScript, di un layer (<div></div>).
Attualmente il codice funziona con MSIE ed Opera ma non con NN e FireFox, però non riesco a capirne il motivo.
Riporto di seguito i tre files interessati e vi ringrazio fin da subito per il vostro gentile interessamento.
Saverio
PAGINA XHTML ("index.html"):
FOGLIO DI STILE ("screen.css"):
codice:
/* CSS Document */
body {
border: 0px none #ffffff;
margin: 0px;
padding: 140px auto;
background-color: #ffffff;
color: #666666;
font-family: arial, verdana, helvetica, sans-serif;
font-size: 12px;
text-align: center;
}
img {
border: 0px none #ffffff;
margin: 0px;
padding: 0px;
}
h1 {
font-size: 32px;
font-weight: bold;
color: #666666;
}
h2 {
font-size: 12px;
font-weight: bold;
color: #78bde8;
}
h3 {
font-size: 12px;
font-weight: bold;
color: #666666;
}
a:link {
color: #666666;
text-decoration: none;
}
a:visited {
color: #666666;
text-decoration: none;
}
a:hover {
color: #b1b1b1;
text-decoration: none;
}
a:active {
color: #666666;
text-decoration: none;
}
.italic {
font-style: italic;
}
.bold {
font-weight: bold;
}
.undeline {
text-decoration: underline;
}
.blue {
color: #78bde8;
}
ul.masked {
border: 0px none #ffffff;
margin: 0px;
padding: 0px;
list-style-type: none;
}
li.masked {
border: 0px none #ffffff;
margin: 0px;
padding: 0px;
text-indent: 0px;
}
/* === HEADER === */
#div_header {
width: 680px;
border: 0px none #ffffff;
margin: 140px auto 30px auto;
padding: 0px;
background-color: #ffffff;
color: #666666;
text-align: right;
}
#titolo {
border: 0px none #ffffff;
margin: 0px auto 0px 0px;
padding: 0px;
color: #666666;
font-size: 32px;
font-weight: bold;
font-family: "times new roman", times, serif;
display: inline;
float: left;
}
#navigazione {
border: 0px none #ffffff;
margin: 0px 0px 0px auto;
padding: 0px;
font-size: 12px;
font-weight: bold;
display: inline;
}
#navigazione li {
border: 0px none #ffffff;
margin: 0px;
padding: 0px 3px;
display: inline;
}
a.nav:link {
color: #666666;
font-weight: bold;
text-decoration: none;
}
a.nav:visited {
color: #666666;
font-weight: bold;
text-decoration: none;
}
a.nav:hover {
color: #b1b1b1;
font-weight: bold;
text-decoration: none;
}
a.nav:active {
color: #666666;
font-weight: bold;
text-decoration: none;
}
/* === BODY === */
#div_body {
width: 680px;
height: 400px;
border: 0px none #00ff00;
margin: 30px auto 10px auto;
padding: 3px 0px;
background-color: #ffffff;
color: #666666;
text-align: justify;
vertical-align: top;
clear: both;
}
#boxLayer {
width: 680px;
height: 106px;
border: 0px none #ffffff;
margin: 0px;
padding: 0px;
overflow: hidden;
}
#contentLayer {
position: relative;
left: 0px;
top: 0px;
height: 106px;
border: 0px none #ffffff;
margin: 0px;
padding: 0px;
background-color: #ffffff;
color: #666666;
text-align: center;
vertical-align: middle;
overflow: hidden;
}
div.sub_navigation {
width: 680px;
border: 0px none #ffffff;
margin: 0px;
padding: 0px auto;
text-align: center;
}
div.left_img {
width: 340px;
height: 400px;
border: 0px none #ffffff;
margin: 0px;
padding: 0px;
}
div.right_txt {
width: 330px;
height: 340px;
overflow: auto;
border: 0px none #ffffff;
margin: 0px;
padding: 0px 3px;
float: right;
}
/* === FOOTER === */
#div_footer {
width: 680px;
border: 0px none #ffffff;
margin: 10px auto 140px auto;
padding: 0px;
background-color: #ffffff;
color: #666666;
font-size: 10px;
text-align: right;
}
a.left_bar {
border-top: 0px none #ffffff;
border-right: 0px none #ffffff;
border-bottom: 0px none #ffffff;
border-left: 1px solid #666666;
margin: 0px 0px 0px 5px;
padding: 0px 0px 0px 5px;
}
CODICE JAVASCRIP ("prodScroll.js"):
codice:
// starts the scrolling
function startProdScroll(dir, spd, loop) {
loop = true;
direction = "left";
speed = 10;
scrolltimer = null;
if (document.layers) {
var page = eval(document.contentLayer);
} else {
if (document.getElementById) {
var page = eval(document.getElementById('contentLayer').style);
} else {
if (document.all) {
var page = eval(document.all.contentLayer.style);
}
}
}
direction = dir;
speed = parseInt(spd);
y_pos = parseInt(page.left);
wmax = parseInt(page.width);
y_limit = -(parseInt(wmax - 680));
if(isNaN(y_pos)) {
y_pos = 0;
}
if (loop == true) {
if (direction == "left") {
if (y_pos < 0) {
page.left = (y_pos + speed);
} else {
page.left = 0;
}
}
if (direction == "right") {
if ((y_pos > y_limit) && (y_pos <= 0)) {
page.left = (y_pos - speed);
} else {
page.left = y_limit;
}
}
}
scrolltimer = setTimeout("startProdScroll(direction,speed)", 1);
}
// stops the scrolling
function stopProdScroll() {
loop = false;
clearTimeout(scrolltimer);
}