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