HTML DOM scrollIntoView နည်းလမ်း
ဥပမာ
ဘရောက်ဆာဝင်းဒိုး၏ မြင်နိုင်သော ဧရိယာသို့ id="content" ဖြင့် ဒြပ်စင်ကို ရွှေ့ပါ-
var elmnt = document.getElementById("content");
elmnt.scrollIntoView();
အောက်တွင် နောက်ထပ် "စမ်းသုံးကြည့်ပါ" ဥပမာများ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
scrollIntoView() နည်းလမ်းသည် သတ်မှတ်ထားသော ဒြပ်စင်အား ဘရောက်ဆာဝင်းဒိုး၏ မြင်နိုင်သော ဧရိယာသို့ လှိမ့်ပေးသည်။
Browser ပံ့ပိုးမှု
ဇယားရှိ နံပါတ်များသည် နည်းလမ်းကို အပြည့်အဝထောက်ခံသည့် ပထမဆုံးဘရောက်ဆာဗားရှင်းကို သတ်မှတ်ပေးပါသည်။
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. |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ပြန်တန်ဖိုးမရှိပါ။ |
---|---|
DOM ဗားရှင်း | သမ္ဘာ |
နောက်ထပ် ဥပမာများ
ဥပမာ
ဒြပ်စင်တစ်ခု၏ အပေါ် သို့မဟုတ် အောက်ခြေသို့ ရွှေ့ပါ-
var elmnt = document.getElementById("content");
function scrollToTop()
{
elmnt.scrollIntoView(true); // Top
}
function scrollToBottom() {
elmnt.scrollIntoView(false); // Bottom
}