No one bothers you in the same way and with the page. On the usual elements of ScrollTop / ScrollLeft, in principle, you can change, and at the same time the item will scroll. In order to scroll through the page when javaScript helpIts all elements must be fully loaded. Var scrollltop \u003d window.pageyoffset || Alert ("Current Scroll:" + ScrollTop) Scroll Changing Page: Scrollto, Scrollby, Scrollintoview If IE8 is not worried, then we simply use these properties.Ĭross-browser version with IE8 provides option on DocumentElement: They can only read them, but it is impossible to change.Well, in order to completely bypass this problem, you can use the properties of the Window.pagexoffset / Pagetyoffset:Īlert ("Current scrolling from above:" + window.pageyoffset) Alert ("Current scrolling on the left:" + window.pagexoffset) The fact is that most browsers will correctly process the DocumentElement.scrollLell / TOP query, however, Safari / Chrome / Opera has errors because you should use document.body. If the conventional element has a current scrolling in ScrollLeft / ScrollTop. Var scrollvisota \u003d math.max (,, ,, , ) Alert ("Height, taking into account scroll:" + scrollvisota) Obtaining current scroll This problem may occur specifically for DocumentElement.īut it is possible to reliably determine the size of the page, taking into account the scroll, simply taking the maximum of these several properties: I must say that in chrome browsers/ Safari and Opera In the absence of a scroll bar value DocumentElement.scrollheight in this case can be even less than documentElement.clientHeight, which, of course, looks like something not logical Yes, theoretically, the visible part of the page is DocumentElement.clientWidth / Height, but the full size taking into account the scroll bar is by analogy, documentElement.scrollwidth / scrollheight.īut for the page with these properties, there may be a problem when the scrolling is there, then it is not. Width / Height of the Web Page taking into account scroll Therefore, DocumentElement.clientWidth is often used. Usually we are only interested in the available window width, for example, to draw something, that is, minus the scroll bar. If the right side of the page takes the scroll bar, then these lines will remove different:Īlert (Window.innerwidth) // All the full ALERT window width () // width less scroll It is certainly small, but extremely important.ĬlientWidth / Height properties, if there is a scroll bar, return the width / height inside it, accessible to the entire document, and window.innerwidth / height - will ignore its presence. It should be noted that all browsers, except IE8, can also support the properties of Window.innerwidth / innerheight. Width / Height of the visible part of the browser window The clientwidth / height properties for the element is just the width / height of the visible window area. How can I find a browser width? How to scroll through javascript web page? Answers to these questions I think you will find in this lesson. Hello! In continuing the topic in this lesson, we will consider such a question as a webpage scrolling and manipulate the browser sizes. Scroll Changing Page: Scrollto, Scrollby, Scrollintoview Sizes of elements and scrolling web page.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |