Open In App

HTML DOM Window scrollMaxX Property

Last Updated : 13 Aug, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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;">
    GeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeksGeeks
    <h1 style="color:green;">
        GeeksforGeeks
    </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

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads