PDA

View Full Version : Scrollbar for div object [JS]



ReMaX
10-23-2007, 07:39 PM
Hi guys,
I just came in here cause I have a problem! I really need a correction for this script to have a scrollbar in a single div object.
I've already found this but it doesn't work in a div object only with the window:
<script language="JavaScript">
pos = 0;
function scroll(wohin)
{
if(wohin == 'd') {
pos += 50;
self.scrollTo(0,pos); }
else {
pos -= 50;
self.scrollTo(0,pos); }
}
</script>
I would be very glad if anybody could help me!!!
...I just started learning JS. So give me simple solutions, please.

jscheuer1
10-23-2007, 11:46 PM
What do you want? Your question isn't all that clear. A division can easily have a scrollbar:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>
<div style="width:100px;height:200px;overflow:auto;">
Got some content here. Got some content here. Got some content here. Got some content here. Got some content here. Got some content here. Got some content here. Got some content here. Got some content here. Got some content here. Got some content here. Got some content here. Got some content here. Got some content here. Got some content here.
</div>
</body>
</html>

ReMaX
10-24-2007, 12:29 AM
Thank for you answering John, but I ment a Scrollbar in JS. Thats why it is posted in here. It is a question of design to have a selfmade scrollbar. Sometimes it is necessary cause normal scrollbars are too ugly in the center of my good design :cool: !!!

jscheuer1
10-24-2007, 02:54 AM
http://www.hesido.com/web.php?page=customscrollbar

ReMaX
10-24-2007, 03:36 AM
Thanks a lot!
But there is a copyright saying that I cannot use it on a commercial site but that's what I want to do!
Could anyone give me the correct code for what I've already written for a div element?!? ...or an easy similar version without or with a free copyright?
Please help? On the other hand: I see you're a great community. Nice...:p
greetings
Max

ReMaX
10-24-2007, 10:00 PM
no answer?!
*push* *push*

jscheuer1
10-24-2007, 10:24 PM
If the site is commercial, you can buy a very inexpensive license.

ReMaX
10-24-2007, 10:48 PM
Yeah, of course I could buy one. But on the one hand I do not have money and on the other hand I don't want to use scripts I did not myself or which I do not understand!
THX

jscheuer1
10-25-2007, 04:10 PM
See:

http://www.dynamicdrive.com/dynamicindex11/domdrag/index.htm

Look down at the bottom of the page, they have a primitive custom scrolling division there.

Really though, any decent drag and drop script that allows you to both confine the range of movement of the dragged item, and to receive information back from the script as to where the item was dragged to, could be used for something like this.