Results 1 to 9 of 9

Thread: Scrollbar for div object [JS]

  1. #1
    Join Date
    Oct 2007
    Location
    Germany, Berlin
    Posts
    41
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Scrollbar for div object [JS]

    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.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    What do you want? Your question isn't all that clear. A division can easily have a scrollbar:

    Code:
    <!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>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Oct 2007
    Location
    Germany, Berlin
    Posts
    41
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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 !!!

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

  5. #5
    Join Date
    Oct 2007
    Location
    Germany, Berlin
    Posts
    41
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post

    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...
    greetings
    Max

  6. #6
    Join Date
    Oct 2007
    Location
    Germany, Berlin
    Posts
    41
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    no answer?!
    *push* *push*

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If the site is commercial, you can buy a very inexpensive license.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Oct 2007
    Location
    Germany, Berlin
    Posts
    41
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    See:

    http://www.dynamicdrive.com/dynamici...drag/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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •