Menu
i’m looking for a javascript snippet that will allow me to take my div with an overflow: auto; to scroll up and down by a hover of the mouse on two different images representing the scroll up and scroll down.
any scripts or snippets that any of you guys know about?
thanks!
[CODE]<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Eddie Traversa ([email protected]) -->
<!-- Web Site: http://nirvana.media3.net -->
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);
}
// End -->
</script>[/CODE]
[CODE]<div id="contentLayer" style="position:absolute; width:300px; height:300px; z-index:1; left: 50px; top: 50px;overflow: auto;">
<img src="image.jpg" width=2400 height=2400 border=0 alt="">
Or text: blah blah blah blah blah blah blah blahblah blah blah blahblah blah blah blahblah blah blah blahblah blah blah blahblah blah blah blahblah blah blah blahblah blah blah blahblah blah blah blahblah blah blah blahblah blah blah blah
</div>[/CODE]
[CODE]
<div id="scrollmenu" style="position:absolute;width:200px;height:30px;z-index:1; left:400px; top: 40px">
<a href="#" onMouseOver="verScroll('up','25','true')" onMouseOut="stopScroll()"><<<</a>
<a href="#" onMouseOver="verScroll('up','5','true')" onMouseOut="stopScroll()"><<</a>
<a href="#" onMouseOver="verScroll('up','1','true')" onMouseOut="stopScroll()"><</a> |
<a href="#" onMouseOver="verScroll('dn','1','true')" onMouseOut="stopScroll()">></a>
<a href="#" onMouseOver="verScroll('dn','5','true')" onMouseOut="stopScroll()">>></a>
<a href="#" onMouseOver="verScroll('dn','25','true')" onMouseOut="stopScroll()">>>></a>
</div>
[/CODE]
Error in parsing value for property 'top'. Declaration dropped.
URL.
[CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Scroll</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#divUpControl{
position:absolute;
width:66px;
left:721px;
top:68px;
z-index:1;
text-align: right;
height: 19px;
}
#divDownControl{
position:absolute;
width:82px;
left:706px;
top:233px;
z-index:1;
text-align: right;
height: 19px;
}
#divContainer{position:absolute; width:702px; height:240px; overflow:hidden; top:30; left:10; clip:rect(0 705 240 0); visibility:visible}
#divContent{position:absolute; top:0; left:0}
</style>
<script language="JavaScript">// begin absolutely positioned scrollable area object scripts
// Extension developed by David G. Miles
// Original Scrollable Area code developed by Thomas Brattli
function verifyCompatibleBrowser(){
this.ver=navigator.appVersion
this.dom=document.getElementById?1:0
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
return this
}
bw=new verifyCompatibleBrowser()
var speed=50
var loop, timer
function ConstructObject(obj,nest){
nest=(!nest) ? '':'document.'+nest+'.'
this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
this.up=MoveAreaUp;this.down=MoveAreaDown;
this.MoveArea=MoveArea; this.x; this.y;
this.obj = obj + "Object"
eval(this.obj + "=this")
return this
}
function MoveArea(x,y){
this.x=x;this.y=y
this.css.left=this.x
this.css.top=this.y
}
function MoveAreaDown(move){
if(this.y>-this.scrollHeight+objContainer.clipHeight){
this.MoveArea(0,this.y-move)
if(loop) setTimeout(this.obj+".down("+move+")",speed)
}
}
function MoveAreaUp(move){
if(this.y<0){
this.MoveArea(0,this.y-move)
if(loop) setTimeout(this.obj+".up("+move+")",speed)
}
}
function PerformScroll(speed){
if(initialised){
loop=true;
if(speed>0) objScroller.down(speed)
else objScroller.up(speed)
}
}
function CeaseScroll(){
loop=false
if(timer) clearTimeout(timer)
}
var initialised;
function InitialiseScrollableArea(){
objContainer=new ConstructObject('divContainer')
objScroller=new ConstructObject('divContent','divContainer')
objScroller.MoveArea(0,0)
objContainer.css.visibility='visible'
initialised=true;
}
// end absolutely positioned scrollable area object scripts
</script>
<title>Scrolling</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<script language="Javascript" type="text/javascript">
window.moveTo (0,0)
window.resizeTo(screen.width,screen.height)
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="InitialiseScrollableArea()">
</div> <div id="Layer1" style="position:absolute; width:99px; height:25px; z-index:1; left: 46px; top: 10px; overflow: visible;">
<!-- begin absolutely positioned scrollable area object-->
<div id="divDownControl"> <a href="javascript:;" onMouseOver="PerformScroll(20)" onMouseOut="CeaseScroll()">Down</a>
</div>
<div id="divUpControl"> <a href="javascript:;" onMouseOver="PerformScroll(-20)" onMouseOut="CeaseScroll()">Up</a>
</div>
<div id="divContainer" style="overflow: auto; ">
<div id="divContent"><b>Scroll Area Content Start</b></p>
<p>Blah dee Blah deeBlah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee </p>
<P>Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee </p><P>Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee </p><P>Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee </p><P>Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee Blah dee </p>
<b>Scroll Area Content End</b> </div>
</div>
<!-- end absolutely positioned scrollable area object -->
</div>
</body>
</html>[/CODE]
function MoveArea(x,y){
this.x=x;this.y=y
this.css.left=this.x
this.css.top=this.y
}
function MoveArea(x,y){
this.x=x;this.y=y
this.css.left=this.x + "px";
this.css.top=this.y + "px";
}
0.1.9 — BETA 5.18