www.webdeveloper.com
Results 1 to 4 of 4

Thread: Horizontal Scrolling Problem

  1. #1
    Join Date
    Jun 2013
    Posts
    2

    Horizontal Scrolling Problem

    I'm trying to make some arrow images activate the scroll feature of a DIV element. The code I'm using supposedly works but I cannot get it to work. Can someone take a look at http://174.120.202.156/~factory/ and let me know why clicking the arrows doesn't scroll the DIV?

    Thanks in advance

    Scott

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,633
    if you were looking at the error console you could see the answer by yourself
    [12.06.2013 1:44:17] JavaScript - http://174.120.202.156/~factory/
    Event thread: click
    Uncaught exception: TypeError: Cannot convert 'scroller' to object
    Error thrown at line 54, column 12 in <anonymous function>(dir, px) in http://174.120.202.156/~factory/:
    scroller.scrollLeft += px;
    called from line 1, column 0 in <anonymous function>(event) in http://174.120.202.156/~factory/:
    scrollDiv('r', 100);
    you have the javascript function which operates with document.getElementById('wrapper2') (twice in the code!! what for?)

    Code:
    <script type="text/javascript">
        var scrollDiv = function(dir, px) {
            var scroller = document.getElementById('wrapper2');
            if (dir == 'l') {
                scroller.scrollLeft -= px;
            }
            else if (dir == 'r') {
                scroller.scrollLeft += px;
            }
        }
    </script>
    but you have no any element having this id
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Jun 2013
    Posts
    2

    Red face Thanks!

    Thank you for your reply. I'm quite new to Javascript and still have a long way to go.

    I was totally missing the ID clue!!! I had a DIV with that class name and just assumed (ugh!) that it would be correct.

    Thanks!!!

    Scott

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,633
    you welcome, Scott. all you needed was just a tip, but you if have the will to go and you way won't be that long )
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles