Visit Mozilla.org

DOM:window.scrollX

From MDC

« Gecko DOM Reference

Contents

[edit] Summary

Returns the number of pixels that the document has already been scrolled horizontally.

[edit] Syntax

var xpix = window.scrollX;

[edit] Parameters

  • xpix is the number of pixels.

[edit] Example

// make sure and go over to the second horizontal page 
if (window.scrollX)
  scroll(0,0);
scrollBy(400, 0);

[edit] Notes

Use this property to check that the document hasn't already been scrolled some if you are using relative scroll functions such as window.scrollBy, window.scrollByLines, or window.scrollByPages.

The pageXOffset property is an alias for the scrollX property:

window.pageXOffset == window.scrollX; // always true

[edit] Specification

DOM Level 0. Not part of specification.