HTML DOM Window scrollMaxX Property

The Window scrollMaxX property returns the maximum number of pixels that the document can be scrolled horizontally in the current window. Window scrollMaxX is a read-only property.
Syntax:
var Scrx = window.scrollMaxX
Return Value: This property returns the maximum number of pixels that the document can be scrolled horizontally.
Example: This example shows how to get the maximum number of pixels horizontally of the document using this property.
Here, I have attached a long text to exceed the frame to enable scroll horizontally.
HTML
<!DOCTYPE HTML> <html> <body style="text-align:center;"> zambiatekzambiatekzambiatekzambiatekzambiatekzambiatekzambiatekzambiatekzambiatekzambiatekzambiatekzambiatekzambiatekzambiatekGeeks <h1 style="color:green;"> zambiatek </h1> <p> HTML | window scrollMaxX property </p> <button onclick="Geeks()"> Click Here </button> <p id="a"></p> <script> var a = document.getElementById("a"); function Geeks() { a.innerHTML = "scrollMaxX is : " + window.scrollMaxX; } </script> </body> </html> |
Output:
-
Before Clicking the Button:
-
After Clicking the Button:
Supported Browsers:
- Firefox
- Opera
- Internet Explorer
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!




