benjamin
11-16-2003, 04:43 AM
i want to have i arrow pictures above and below a div so that when you hover over them the div scrolls automatically in the respective direction. any help?
|
Click to See Complete Forum and Search --> : Function to make a div scroll automatically benjamin 11-16-2003, 04:43 AM i want to have i arrow pictures above and below a div so that when you hover over them the div scrolls automatically in the respective direction. any help? Mr J 11-16-2003, 12:14 PM See if the following helps you <SCRIPT LANGUAGE = "JavaScript"> <!-- left_start=100 right_stop=500 pos_now=left_start timer1="" timer2="" function right() { clearTimeout(timer2) if (pos_now < right_stop) { pos_now += 10 } timer1=setTimeout('right()', 10); if(pos_now>right_stop){ pos_now=right_stop clearTimeout(timer1) } document.getElementById("moveme").style.left =pos_now } function left() { clearTimeout(timer1) if (pos_now > left_start) { pos_now -= 15 } timer2=setTimeout('left()', 30); if(pos_now<left_start){ pos_now=left_start clearTimeout(timer2) } document.getElementById("moveme").style.left = pos_now } //--> </SCRIPT> <DIV ID = "moveme" style="position:absolute;top:50; left:50">OBJECT</DIV> <P> <a href="#null" onclick="right()">Move Right</a> <a href="#null" onclick="left()">Move Left</a> benjamin 11-17-2003, 12:56 AM i want it to be a verticle scroll and the div position to be relative; it will be where the main content goes plus i want hover buttons not clickable and so that when i reomve the hover i want the scrolling to cease i dont want the whole script all i want is to know what part of javascript tells a div to scroll a specific no. of cells Mr J 11-17-2003, 12:41 PM My previous post was only an example of how to move a object, not necessarily the solution to your question. If you are wanting to scroll vertically then you would use document.getElementById("moveme").style.top instead of document.getElementById("moveme").style.left Use onmouseover instead of onclick to move the object To stop onmouseout you create a function to cancel timer1 and timer2 To use images for the mouse events you can nest the image tags between A tags or use divs with a mouse event benjamin 11-19-2003, 01:18 AM thank you for your support but it is not exactly what i want i want the div to be like an iframe and i want it to scroll not move, this is an alternative to scrollbars what you have sent me just pushes the thing across or downhttp://www.rollingtank.com/benjoffe/head.gif :D DaveSW 11-19-2003, 10:37 AM Colorful language there... LOL How about using an iframe with a custom scrollbar? as Pyro has done here http://www.infinitypages.com/research/iframecustomscroller.htm If you particularly need a div solution, maybe you could 1) adapt Pyro's code 2) pay Pyro to find out if it's possible. Mr J 11-19-2003, 11:22 AM Like this maybe <script language="JavaScript"> <!-- var Last="" var current="" function swaplayer(thislayer){ elm=document.getElementById(thislayer) last_elm=document.getElementById(Last) elm.style.top=0 // set layer to top of container if(Last!=""&&Last!=thislayer){ last_elm.style.visibility="hidden" } elm.style.visibility="visible" Last=thislayer current=thislayer } setTimeout("swaplayer('One')",1000) // show initial layer var timer="" var speed=5 var scroll_rate=3 function movedown(){step=-scroll_rate;dir=0;motion()} function moveup(){step=scroll_rate;dir=1;motion()} function motion(){ if(current==""){return} current_elm=document.getElementById(current) clearTimeout(timer) posnow=parseInt(current_elm.style.top) if(dir==1&& posnow>-5 || dir==0&&posnow<-parseInt(current_elm.scrollHeight)+parseInt(document.getElementById("cont").offsetHeight)){ cease() } else{ posnow+=step current_elm.style.top=posnow timer=setTimeout("motion()",speed) } } function cease(){ clearTimeout(timer) } function otop(){ current_elm.style.top=0 } // --> </script> <a href="javascript:swaplayer('One')">Layer 1</a> <a href="javascript:swaplayer('Two')">Layer 2</a> <a href="javascript:swaplayer('Three')">Layer 3</a> <a href="javascript:swaplayer('Four')">Layer 4</a> <a href="javascript:swaplayer('Five')">Layer 5</a> [ <a href="#null" onmouseover="movedown()" onmouseout="cease()">Down</a> || <a href="#null" onmouseover="moveup()" onmouseout="cease()">Up</a> || <a href="#null" onclick="otop()">Top</a> ] <DIV id=cont style="position:absolute; left:300; top:120;width:300; height:200; CLIP:rect(0px 300px 200px 0px);border:2 solid blue"> <div id="One" style="position:absolute; left:0; top:0; width:300; height:200; visibility:visible;font-size:30"> "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." </div> <div id="Two" style="position:absolute; left:0; top:0;width:300; height:200; background-color: #AAAA00; color:black;visibility:hidden"> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur </div> <div id="Three" style="position:absolute; left:0; top:0;width:300; height:200; background-color: #FF0000; color:black;visibility:hidden">At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, *** soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat</div> <div id="Four" style="position:absolute; left:0; top:0;width:300; height:200; color:black;visibility:hidden;FLOAT:right"> LAYER 4 CONTENTS </div> <div id="Five" style="position:absolute; left:0; top:0;width:300; height:200; background-color: gold; color:black;visibility:hidden;text-align:left"> LAYER 5 CONTENTS </div> </DIV> webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |