<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
body{
width:3000px;
height:3000px;
}
p,button{
margin-left:200px;
}
</style>
</head>
<body>
<p>Scroll the horizontal scroll bar towards right or left at different position and click 'pageXOffset' button.</p>
<button onclick="myFunction()">pageXOffset</button>
<script>
window.scrollBy({
top: 0,
left: 100,
behavior: 'auto'
});
function myFunction(){
alert("Scroll Left: "+window.pageXOffset);
}
</script> </body>
</html>