need a bit of code. Interesting idea

Discussion in 'JavaScript' started by Notting, Dec 7, 2006.

  1. #1
    Hi guys!

    Im looking for a bit of code that will:

    when people scroll down the page, bring the page straight back to the top. Ie, people can try to scroll down but cant.

    Any ideas?

    Notting
     
    Notting, Dec 7, 2006 IP
  2. The_FoX

    The_FoX Peon

    Messages:
    666
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #2
    this can be done if they click on a link(that has to be fixed somewhere) that link should point to an anchor point at the top of the page.

    but i dunno how it can be done without clicking. hope this interests you.
     
    The_FoX, Dec 7, 2006 IP
  3. heinlein99

    heinlein99 Peon

    Messages:
    538
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    So if they hold the scrollbar down they can see stuff down the page, but if they let go, it snaps them back up to the top?

    I guess I can see some value in that. Sneaky.
     
    heinlein99, Dec 7, 2006 IP
  4. Notting

    Notting Notable Member

    Messages:
    3,210
    Likes Received:
    335
    Best Answers:
    0
    Trophy Points:
    280
    #4
    You hit the nail right on the head heinlein99!

    Anyone got any suggestions for this one?
    Notting
     
    Notting, Dec 7, 2006 IP
  5. smallbuzz

    smallbuzz Peon

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sounds like a really annoying "feature" though, why do you want to do this?
     
    smallbuzz, Dec 7, 2006 IP
  6. rgchris

    rgchris Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    IMHO it will just drive people away from your site. I know that I'd personally hate it.
     
    rgchris, Dec 7, 2006 IP
  7. the_pm

    the_pm Peon

    Messages:
    332
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Not that I'm condoning this type of behavior, but the following script will do the trick (I can't think of any way to do this other than JavaScript, which can be disabled).

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    <head>
    	<title>Untitled</title>
    	<script type="text/javascript">
    		function jump() {
    			window.location = "#top";
    		}
    		document.onmousemove = jump;
    	</script>
    </head>
    
    <body>
    <a name="top"></a>
    
    <!-- All your content goes after the <a name> tag -->
    
    </body>
    </html>
    Code (markup):
    The script itself and the <a name="top"></a> parts are the only important pieces.
     
    the_pm, Dec 7, 2006 IP
    Notting likes this.
  8. Notting

    Notting Notable Member

    Messages:
    3,210
    Likes Received:
    335
    Best Answers:
    0
    Trophy Points:
    280
    #8
    Thanks - rep left
    Notting
     
    Notting, Dec 7, 2006 IP
  9. the_pm

    the_pm Peon

    Messages:
    332
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks Notting :)

    Glad to help.
     
    the_pm, Dec 7, 2006 IP
  10. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #10
    I gotta say I wouldn't be staying too long as a visitor on a site with that sorta thing going on, think about that....

    Most ppl will just think this page is broken and never come back.....
     
    krakjoe, Dec 11, 2006 IP
  11. Notting

    Notting Notable Member

    Messages:
    3,210
    Likes Received:
    335
    Best Answers:
    0
    Trophy Points:
    280
    #11
    thats fine, i hope they leave really quickly!
     
    Notting, Dec 11, 2006 IP
  12. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #12
    This trick not always work: you can scroll down the page with the "down" key (without moving mouse of course).
    A better trick is using a timer that several times a second executes function jump().
    And instead of
    window.location = "#top";
    Code (markup):
    you can use
    window.scroll(0,0);
    Code (markup):
    or wherever position you want.

    Using window.scroll(x,y) with different values for x and y each time your visitor will go crazy ;)
     
    ajsa52, Dec 11, 2006 IP