Skip to content
Related Articles

Related Articles

Improve Article

HTML DOM Window scrollMaxX Property

  • Last Updated : 13 Aug, 2020

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

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :