Javascript 元素scrollIntoView在safari中不起作用
此函数用于将元素获取到视图中Javascript 元素scrollIntoView在safari中不起作用,javascript,safari,Javascript,Safari,此函数用于将元素获取到视图中 if (elmement) { const rect = elmement.getBoundingClientRect(); if (rect.top < 0 ) { elmement.scrollIntoView(true ); } else if (rect.bottom > window.innerHeight) { elmement.scrollIntoView(rect.top
if (elmement) {
const rect = elmement.getBoundingClientRect();
if (rect.top < 0 ) {
elmement.scrollIntoView(true );
} else if (rect.bottom > window.innerHeight) {
elmement.scrollIntoView(rect.top <= 0);
}
}
if(elment){
const rect=elment.getBoundingClientRect();
如果(矩形顶部<0){
elment.scrollIntoView(true);
}else if(rect.bottom>window.innerHeight){
ElMent.scrollIntoView(rect.top)这是否回答了您的问题?@NeutralMe nope在safari scrollIntoView中支持布尔值,我正在发送boolean我认为它不受支持,如果您仔细查看,您会看到它说部分支持。这意味着不完全支持。如果您转到,它会说它在iOS上不支持safari。