SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    position after scroll

    Please anyone (but no insects!!)
    How do I get the screen position after scroll?
    I want to move an object down as the screen is scrolled.

    Thanks
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exporer has a onScroll event in which you can attach a function to get the current scroll postion, but Netscape doesn't have this event, so you have to set an interval to check the scroll position even if the user isn't scrolling the window.

    here's the code need to capture the scroll position.

    Code:
    function captureScroll(){
    	var currentScroll = document.all ? document.body.scrollTop : window.pageYOffset;
    	// INSERT YOUR CODE HERE.
    	// The var "currentScroll" contains the scroll position of the window.
    }
    window.onload = function(){
    	if(document.all){
    		document.body.onscroll = captureScroll;
    	}else{
    		scrollInterval = setInterval('captureScroll()',250);
    	}
    }
    Here's a link to a little demo.
    http://travis.squidfingers.com/scroll.html
    Last edited by podlob; Nov 23, 2002 at 10:18.
    travis

  3. #3
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Can I use onMouseup on scroller?

    Thanks Travis

    Is there a way of attaching events to the scrollbar?
    I could use the onMouseup of the scrollbar to trigger rather than have it constantly checking.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope. There's not much control over the scrollbar.
    travis


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
  •