Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: "save my place"

  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Location
    USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "save my place"

    My pages are pretty lengthy with a lot of information and I was looking for a code that might help my viewers to click on a line or section to help them "save their place", so that when they finish reading they can go back to where they clicked.

    Does anyone know of such a code? If not, could you point me in the right direction where I can get help?

    Thanks
    eyecnn

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Works in ie4+, ns6, mozilla 1.0. I labeled everything in case you want to use something else than a keypress.

    <html>

    <head>

    <script>

    // START OF - keypress script

    function key (e) {
    var thekey =
    document.layers ? e.which :
    document.all ? event.keyCode :
    document.getElementById ? e.keyCode : 0;
    if (thekey==16) { savepos(); }
    if (thekey==17) { jump(); }
    return false;
    }

    // END OF - keypress script

    // START OF - browser detect

    ns6 = false;
    ie4 = false;
    if (navigator.appName=="Netscape"&&parseInt(navigator.appVersion)>=5) { ns6 = true; }
    if (navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)>=4) { ie4 = true; }

    // END OF - browser detect

    // START OF - save position script

    function savepos() {
    if (ie4) {
    ypos = document.body.scrollTop;
    xpos = document.body.scrollLeft;
    }
    if (ns6) {
    xpos = window.pageXOffset;
    ypos = window.pageYOffset;
    }
    }

    // END OF - save position script

    // START OF - return to save point

    function jump() {
    window.scrollTo(xpos,ypos)
    }

    // END OF - return to save point

    </script>

    </head>

    <body onkeydown="return key(event);">

    Press Shift to save a point.<br>
    Press Ctrl to return to that save point.

    </body>

    </html>

    If you want to change what key is pressed to do what use the following script:

    <html>

    <head>

    <script>
    function key (e) {
    var thekey =
    document.layers ? e.which :
    document.all ? event.keyCode :
    document.getElementById ? e.keyCode : 0;
    window.status=thekey;
    return false;
    }

    </script>

    </head>

    <body onkeydown="return key(event)">

    </body>

    </html>

    When you press a key it gives you the keycode in the status bar.
    Last edited by x_goose_x; 06-16-2002 at 08:33 PM.

  • #3
    New to the CF scene
    Join Date
    Jun 2002
    Location
    USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thank you!

    x_goose_x

    Thanks so much, I really appreciate the code!

    Candy


  •  

    Posting Permissions

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