JSFiddle - React, Tailwind, and code Playground
HTML
<div class="content">
<div class="sideBar"></div>
</div>
CSS
html, body {
}
.content {
border:1px solid black;
}
.sideBar {
height:1200px;
margin:5px;
background:red;
}
JavaScript
function getScrollXY() {
var x = 0, y = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
// Netscape
x = window.pageXOffset;
y = window.pageYOffset;
} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
// DOM
x = document.body.scrollLeft;
y = document.body.scrollTop;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
// IE6 standards compliant mode
x = document.documentElement.scrollLeft;
y = document.documentElement.scrollTop;
}
return [x, y];
}
console.log(getScrollXY());
window.scrollTo(0, 0);
$(document).ready(function(){
window.scrollTo(0, 0);
});
$(window).load(function(){
window.scrollTo(0, 0);
});