Scoller - problems ...
Jeg har fået smækket noget kode sammen til en scroller, som en slags erstatning for en iframe pga. problemer med nogle z-index's ...Koden er som følger:
<html>
<head>
<script language="javascript">
function verScroll(dir, spd, loop) {
loop = true;
direction = "up";
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);
var y_pos = parseInt(page.top);
if (loop == true) {
if (direction == "dn") {
page.top = (y_pos - (speed));
}
else {
if (direction == "up" && y_pos < 10) {
page.top = (y_pos + (speed));
}
else {
if (direction == "top") {
page.top = 10;
}
}
}
scrolltimer = setTimeout("verScroll(direction,speed)", 1);
}
}
function stopScroll() {
loop = false;
clearTimeout(scrolltimer);
}
</script>
</head>
<body>
<div id="contentLayer" style="position: absolute; width: 300px; height: 200px; z-index: 1; left: 39px; top: 51px">
insert your text here !!<br><br><br><br>
insert your text here !!<br><br><br><br>
insert your text here !!<br><br><br><br>
insert your text here !!<br><br><br><br>
insert your text here !!<br><br><br><br>
insert your text here !!<br><br><br><br>
insert your text here !!<br><br><br><br>
insert your text here !!<br><br><br><br>
insert your text here !!<br><br><br><br>
insert your text here !!<br><br><br><br>
insert your text here !!<br><br><br><br>
insert your text here !!<br><br><br><br>
</div>
<div id="scrollmenu" style="position: absolute; width: 200px; height: 30px; z-index: 1; left: 400px; top: 40px">
<table border="1">
<tr>
<td>
<table>
<tr>
<td align="left">
Up
</td>
<td> </td>
<td align="right">
Down
</td>
</tr>
<tr>
<td colspan="3">
<a href="#" onMouseDown="verScroll('up','25','true')" onMouseUp="stopScroll()">
<<<
</a>
<a href="#" onMouseDown="verScroll('up','5','true')" onMouseUp="stopScroll()">
<<
</a>
<a href="#" onMouseDown="verScroll('up','1','true')" onMouseUp="stopScroll()">
<
</a>
|
<a href="#" onMouseDown="verScroll('dn','1','true')" onMouseUp="stopScroll()">
>
</a>
<a href="#" onMouseDown="verScroll('dn','5','true')" onMouseUp="stopScroll()">
>>
</a>
<a href="#" onMouseDown="verScroll('dn','25','true')" onMouseUp="stopScroll()">
>>>
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
Mit problem er at jeg ikke kan regulere højden af det div tag der indeholder den tekst der skal scrolles og jeg kan heller ikke finde ud af hvordan jeg får scrolleren til at stoppe nå "bunden" er nået ...
Håber der er nogen der kan hjælpe ...
Thomas
