Window scrollBy()
ဥပမာ
စာရွက်စာတမ်းကို 100px အလျားလိုက်ရွှေ့ပါ-
window.scrollBy(100, 0);
စာရွက်စာတမ်းကို 100px ဒေါင်လိုက်ရွှေ့ပါ-
window.scrollBy(0, 100);
အောက်တွင် နောက်ထပ် ဥပမာများ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
နည်းလမ်း သည် scrollBy()
သတ်မှတ်ထားသော ပစ်ဆယ်အရေအတွက်ဖြင့် စာရွက်စာတမ်းကို လှိမ့်ပေးသည်။
မှတ်ချက်
နည်းလမ်းအလုပ်လုပ်ရန် အတွက် scrollBy()
၊ စာရွက်စာတမ်းသည် စခရင်ထက် ပိုကြီးရမည်ဖြစ်ပြီး၊ scrollbar ကို မြင်ရပါမည်။
ကိုလည်းကြည့်ပါ-
အထားအသို
window.scrollBy(x, y)
သို့မဟုတ် ရုံ-
scrollBy(x, y)
ကန့်သတ်ချက်များ
Parameter | Description |
x | Required. Number of pixels to scroll (horizontally). Positive values scroll to the right, negative values to the left. |
y | Required. Number ofpixels to scroll (vertically). Positive values scroll down, negative values scroll up. |
တန်ဖိုးကို ပြန်ပေးသည်။
မရှိပါ။ |
နောက်ထပ် ဥပမာများ
စာရွက်စာတမ်းကို အပေါ်နှင့်အောက် ရွှေ့ပါ-
<button onclick="scrollWin(0, 50)">Scroll down</button>
<button onclick="scrollWin(0, -50)">Scroll up</button>
<script>
function scrollWin(x, y) {
window.scrollBy(x, y);
}
</script>
စာရွက်စာတမ်းကို ညာဘက်နှင့် ဘယ်ဘက်သို့ ရွှေ့ပါ-
<button onclick="scrollWin(100, 0)">Scroll right</button>
<button onclick="scrollWin(-100, 0)">Scroll left</button>
<script>
function scrollWin(x, y) {
window.scrollBy(x, y);
}
</script>
Browser ပံ့ပိုးမှု
scrollBy()
ဘရောက်ဆာအားလုံးတွင် ထောက်ခံသည်-
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |