PDA

View Full Version : Javascript onsumbit to Disable Scroll



spam_banjo
08-01-2007, 03:30 PM
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.

tech_support
08-02-2007, 10:04 AM
Haha. Easy:


window.onscroll=function() { window.scrollTo(0,0) }

spam_banjo
08-02-2007, 10:27 AM
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! :D

spam_banjo
08-02-2007, 10:40 AM
In the end I had to use


scroll(0,0)

instead of


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 (http://www.sites4biz.co.uk/whois-domain-name-search.asp)


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

Here's the whole function for future reference.


<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:


<body onscroll="scrolltop();" >