Log in

View Full Version : Slight change to an old DD script



snakester
06-11-2014, 03:27 AM
i have used this scroller on several sites and it works great. the problem is on a new site i want to scroll left to right instead of top to bottom....
tnx in advance.


<script>


//Page Scroller (aka custom scrollbar)- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var Hoffset=#apos# //Enter buttons' offset from right edge of window (adjust depending on images width)
var Voffset=40 //Enter buttons' offset from bottom edge of window (adjust depending on images height)
var thespeed=6 //Enter scroll speed in integer (Advised: 1-3)

var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1
var myspeed=0

var ieHoffset_extra=document.all? 15 : 0
var cross_obj=document.all? document.all.staticbuttons : document.getElementById? document.getElementById("staticbuttons") : document.staticbuttons

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function positionit(){
var dsocleft=document.all? iecompattest().scrollLeft : pageXOffset
var dsoctop=document.all? iecompattest().scrollTop : pageYOffset
var window_width=ieNOTopera? iecompattest().clientWidth+ieHoffset_extra : window.innerWidth+ieHoffset_extra
var window_height=ieNOTopera? iecompattest().clientHeight : window.innerHeight

if (document.all||document.getElementById){
cross_obj.style.left=parseInt(dsocleft)+parseInt(window_width)-Hoffset+"px"
cross_obj.style.top=dsoctop+Voffset+"px"
}
else if (document.layers){
cross_obj.left=dsocleft+window_width-Hoffset
cross_obj.top=dsoctop+window_height-Voffset
}
}

function scrollwindow(){
window.scrollBy(0,myspeed)
}

function initializeIT(){
positionit()
if (myspeed!=0){
scrollwindow()
}
}

if (document.all||document.getElementById||document.layers)
setInterval("initializeIT()",20)

</script>

vwphillips
06-11-2014, 08:43 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
<style type="text/css">
/*<![CDATA[*/
.left {
position:fixed;left:50px;bottom:50px;width:50px;height:50px;background-Color:red;
}

.right {
position:fixed;right:50px;bottom:50px;width:50px;height:50px;background-Color:red;
}

/*]]>*/
</style>.left
</head>

<body>

<div class="left" onmouseover="scrollwindow.spd=-10;" onmouseout="scrollwindow.spd=0;"></div>
<div class="right" onmouseover="scrollwindow.spd=10;" onmouseout="scrollwindow.spd=0;"></div>
<div style="width:5000px;height:50px;background-Color:red" >

</div>

<script type="text/javascript">
/*<![CDATA[*/

function scrollwindow(){
if (scrollwindow.spd&&typeof(scrollwindow.spd)=='number'){
window.scrollBy(scrollwindow.spd,0);
}
}

setInterval(function(){ scrollwindow(); },50);

/*]]>*/
</script>
</body>

</html>

or


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
<style type="text/css">
/*<![CDATA[*/
.left {
position:fixed;left:50px;bottom:50px;width:50px;height:50px;background-Color:red;
}

.right {
position:fixed;right:50px;bottom:50px;width:50px;height:50px;background-Color:red;
}

.up {
position:fixed;left:50px;top:150px;width:50px;height:50px;background-Color:red;
}

.down {
position:fixed;right:50px;top:150px;width:50px;height:50px;background-Color:red;
}

/*]]>*/
</style>.left
</head>

<body>

<div style="width:5000px;height:5050px;background-Color:blue" >
</div>

<div class="up" onmouseover="scrollwindow(0,-10);" onmouseout="scrollwindow();">Up</div>
<div class="down" onmouseover="scrollwindow(0,10);" onmouseout="scrollwindow();">Down</div>

<div class="left" onmouseover="scrollwindow(-10,0);" onmouseout="scrollwindow();">Left</div>
<div class="right" onmouseover="scrollwindow(10,0);" onmouseout="scrollwindow();">Right</div>


<script type="text/javascript">
/*<![CDATA[*/

function scrollwindow(x,y){
clearTimeout(scrollwindow.to);
if (typeof(x)=='number'&&typeof(y)=='number'){
window.scrollBy(x,y);
scrollwindow.to=setTimeout(function(){ scrollwindow(x,y); },50);
}
}


/*]]>*/
</script>
</body>

</html>