HTML DOM scrollIntoView- metode
Voorbeeld
Rollees die element met id="content" in die sigbare area van die blaaiervenster:
var elmnt = document.getElementById("content");
elmnt.scrollIntoView();
Meer "Probeer dit self" voorbeelde hieronder.
Definisie en gebruik
Die scrollIntoView() metode blaai die gespesifiseerde element in die sigbare area van die blaaiervenster.
Blaaierondersteuning
Die nommers in die tabel spesifiseer die eerste blaaierweergawe wat die metode ten volle ondersteun.
Method | |||||
---|---|---|---|---|---|
scrollIntoView | 28.0 | 8.0 | 1.7 | 5.0 | 38.0 |
Sintaksis
element.scrollIntoView(alignTo)
Grense
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. |
Tegniese besonderhede
Terugkeerwaarde: | Geen terugkeerwaarde nie |
---|---|
DOM weergawe | Eksperimenteel |
Meer voorbeelde
Voorbeeld
Rollees na bo of na onder van 'n element:
var elmnt = document.getElementById("content");
function scrollToTop()
{
elmnt.scrollIntoView(true); // Top
}
function scrollToBottom() {
elmnt.scrollIntoView(false); // Bottom
}