Prevent page from scrolling to top

Hello,

i need some help with some javascript and or jquery that can prevent users form scrolling to the very top of my web page i need the top to always stop at about 74pixels
LVL 1
Chris JonesLead Application Web DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

plusone3055Commented:
0
Chris JonesLead Application Web DeveloperAuthor Commented:
i am not sure if this will work the user can scroll with there mouse i need some java to set the boundaries maybe so the user cant scroll to the very top.
0
Chris JonesLead Application Web DeveloperAuthor Commented:
just an update i did try the code and i could still scroll to the top.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

plusone3055Commented:
sorry my bad :(
0
Tom BeckCommented:
I'm probably missing the point too. If users cannot scroll to the top of the page then is the top 74px hidden from view at all times? Maybe a negative top margin on the body (although I cannot imagine why you would want this).

body {
   margin-top: -74px
}

Or do you mean the top is visible on initial load but once the user scrolls, they cannot scroll back high enough to see the top 74 pixels?
$(document).ready(function(){
	$(window).on('scroll', function(){
		if ($(this).scrollTop() > 74) {
			$('body').css('margin-top', '-74px');
		}
	});
});

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris JonesLead Application Web DeveloperAuthor Commented:
your exampled worked that's what i was trying to achieve the header has a slight issue when it scrolls back so a stop gap prevent from scrolling to the very top.
0
Tom BeckCommented:
Not clear. Is there a question or was that just an update?
0
Chris JonesLead Application Web DeveloperAuthor Commented:
this was just an update
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.