एचटीएमएल डोम स्क्रॉलइनटू व्यू मेथड
उदाहरण
ब्राउज़र विंडो के दृश्य क्षेत्र में id="content" वाले तत्व को स्क्रॉल करें:
var elmnt = document.getElementById("content");
elmnt.scrollIntoView();
नीचे और अधिक "इसे स्वयं आज़माएं" उदाहरण।
परिभाषा और उपयोग
स्क्रॉलइन्टोव्यू () विधि निर्दिष्ट तत्व को ब्राउज़र विंडो के दृश्य क्षेत्र में स्क्रॉल करती है।
ब्राउज़र समर्थन
तालिका में संख्याएं पहले ब्राउज़र संस्करण को निर्दिष्ट करती हैं जो पूरी तरह से विधि का समर्थन करता है।
Method | |||||
---|---|---|---|---|---|
scrollIntoView | 28.0 | 8.0 | 1.7 | 5.0 | 38.0 |
वाक्य - विन्यास
element.scrollIntoView(alignTo)
मापदंडों
Parameter | Type | Description |
---|---|---|
alignTo | Boolean | Optional. A boolean value that indicates the type of the align:
true - the top of the element will be aligned to the top of the visible area of the scrollable ancestor false - the bottom of the element will be aligned to the bottom of the visible area of the scrollable ancestor. If omitted, it will scroll to the top of the element. Note: Depending on the layout of other elements, some elements may not be scrolled completely to the top or to the bottom. |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | कोई वापसी मूल्य नहीं |
---|---|
डोम संस्करण | प्रयोगात्मक |
और ज्यादा उदाहरण
उदाहरण
किसी तत्व के ऊपर या नीचे स्क्रॉल करें:
var elmnt = document.getElementById("content");
function scrollToTop()
{
elmnt.scrollIntoView(true); // Top
}
function scrollToBottom() {
elmnt.scrollIntoView(false); // Bottom
}