I have used a piece of javascript code to scroll the main content of my website, this works well but I want to externally import from a javascript file format.I have tried many ways for the solution of this problem but have not managed to solve it . below is the javascript source code and the HTML that I will be using it in.
JavaScript code:
HTML
========
(container is the div that is to be scrolled)
I would appreciate your help very much on how to link this code externally..
Thanks :)
- L33T(leet)
JavaScript code:
Code:
<script type="text/javascript">
scrollStep=3
timerUp=""
timerDown=""
function toTop(id){
document.getElementById(id).scrollTop=0
}
function scrollDivDown(id){
clearTimeout(timerDown)
document.getElementById(id).scrollTop+=scrollStep
timerDown=setTimeout("scrollDivDown('"+id+"')",5)
}
function scrollDivUp(id){
clearTimeout(timerUp)
document.getElementById(id).scrollTop-=scrollStep
timerUp=setTimeout("scrollDivUp('"+id+"')",10)
}
function toBottom(id){
document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
}
function stopMe(){
clearTimeout(timerDown)
clearTimeout(timerUp)
}
</script>
HTML
========
Code:
<div id="scroll">
<a onclick="toTop('container')"> Top </a>
<a onmouseover="javascript:scrollDivDown('container');" onmouseout="stopMe();"> Scroll Down </a>
<a onmouseover="scrollDivUp('container')" onmouseout="stopMe()"> Scroll Up </a>
<a onclick="toBottom('container')"> Bottom </a>
</div>
I would appreciate your help very much on how to link this code externally..
Thanks :)
- L33T(leet)
Comment