طريقة التمرير في HTML DOM
مثال
قم بتمرير العنصر بالمعرف = "المحتوى" في المنطقة المرئية من نافذة المتصفح:
var elmnt = document.getElementById("content");
elmnt.scrollIntoView();
المزيد من الأمثلة "جربها بنفسك" أدناه.
التعريف والاستخدام
تقوم طريقة 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. |
تفاصيل تقنية
قيمة الإرجاع: | لا قيمة مردودة |
---|---|
إصدار DOM | تجريبي |
مزيد من الأمثلة
مثال
قم بالتمرير إلى أعلى عنصر أو أسفله:
var elmnt = document.getElementById("content");
function scrollToTop()
{
elmnt.scrollIntoView(true); // Top
}
function scrollToBottom() {
elmnt.scrollIntoView(false); // Bottom
}