I created a div that matches the height and width of the window to simulate a "home screen." When scrolling down to view the content, everything works fine. However, after refreshing the browser, it automatically scrolls back to where you were before. I want it to start at the top of the page instead. Any suggestions on how to fix this?
Here is the code I'm using:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="jquery/jquery-1.11.2.min.js"></script>
</head>
<style>
html,body,p,h1,h2,div,section,img{
margin:0;
padding:0;
}
html,body{
background:rgba(255,255,255,1.00);
}
header{
background-color:rgba(181,255,0,0.51);
width:100%;
/* flex container */
display: flex;
flex-flow: row no-wrap;
justify-content: center;
}
section{
text-align:center;
}
</style>
<body>
<header></header>
<section>
<h2>Text</h2>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
</section>
</body>
<script>
$(document).ready(function(){
$(window).scroll(function(){
console.log($(window).scrollTop());
});
//screen size
var windowh = $(window).height();
var windoww = $(window).width();
//header full screen
console.log(windowh + ' '+windoww);
$('header').css({
'height': windowh,
});
});
</script>
</html>