Results 1 to 4 of 4

Thread: Javascript onsumbit to Disable Scroll

  1. #1
    Join Date
    Dec 2006
    Location
    Near Derby, UK
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Javascript onsumbit to Disable Scroll

    I need to disable scroll with javascript for an online application I am designing.

    I need to do this because the ASP script in the background is quite slow, and I want to fade out the site using a 40% opacity PNG (Like lightbox) and display a please wait animation so the user knows the site is doing something and not just hanging.

    For the best compatibility, I will make the page scroll to the top > then display the blackout layer with the animation > I wan't to disable scrolling on the page at this point to negate the need for an update-layer-position script, thus keeping the page's file size down.

    Could anyone tell me how to disable the scroll using JavaScript???

    I would appreciate no "Don't Violate My Browser Rights" garbage posts. And I'd also appreciate it if you didn't post back asking me why I am doing it this way. It's the result I want, and I know how it can be achieved. I'm simply not willing to over code this thing. I am not writing the JavaScript direct to the html page (It has to be written into an ASP string) else I would find a more attractive solution.

    Thanks in advance.
    Last edited by spam_banjo; 08-01-2007 at 03:32 PM. Reason: missed the point!

  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Haha. Easy:
    Code:
    window.onscroll=function() { window.scrollTo(0,0) }
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  3. #3
    Join Date
    Dec 2006
    Location
    Near Derby, UK
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ha! You beat me to it! It clicked last night but only just got into work!! JavaScript has the ability to make you feel like such a dumbass some times!!

    Thanks anyway!

  4. #4
    Join Date
    Dec 2006
    Location
    Near Derby, UK
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    In the end I had to use

    HTML Code:
    scroll(0,0)
    instead of

    HTML Code:
    window.scrollTo(0,0)
    as it didn't work in Firefox. Didn't get round to IE.

    I was using on this page this page


    EDIT: -----------------------------------------------------------------------------

    Here's the whole function for future reference.

    HTML Code:
    <SCRIPT type="text/javascript" language="Javascript">
    <!--
    
    // You need to set 'stop_scroll = true' to disable scroll completely
    // You can also set to true using a function to disable on an event 
    
    var stop_scroll = false ;
    
    function scrolltop(){
        if(stop_scroll ==true){
            scroll(0,0) ;
        }
    }
    
    -->
    </script>
    Your body tag should also look like this:

    HTML Code:
    <body onscroll="scrolltop();" >
    Last edited by spam_banjo; 08-02-2007 at 10:57 AM. Reason: Added full function

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
  •