---
title: "滚动条位置"
author: "RandyWei"
date: "2012-11-12T15:51:43Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2012-11-12T15:51:43Z"
id: 1723058
url: "https://randywei.iteye.com/blog/1723058"
---

```
function  ScollPostion() {//滚动条位置
        var t, l, w, h;
        if (document.documentElement && document.documentElement.scrollTop) {
            t = document.documentElement.scrollTop;
            l = document.documentElement.scrollLeft;
            w = document.documentElement.scrollWidth;
            h = document.documentElement.scrollHeight;
        } else if (document.body) {
            t = document.body.scrollTop;
            l = document.body.scrollLeft;
            w = document.body.scrollWidth;
            h = document.body.scrollHeight;
        }
        return { top: t, left: l, width: w, height: h };
    }
```