optimize javascript scrollIntoView

This commit is contained in:
xiaoyifang 2021-10-20 23:44:24 +08:00
parent 9857ed0559
commit 66ed1c0507

View file

@ -752,7 +752,7 @@ void ArticleView::setCurrentArticle( QString const & id, bool moveToIt )
return; // No action on background page, scrollIntoView there don't work
if(moveToIt){
QString script=QString(" document.getElementById('%1').scrollIntoView(true);").arg(id);
QString script=QString(" var elem=document.getElementById('%1'); if(elem!=undefined){elem.scrollIntoView(true);}").arg(id);
ui.definition->page()->runJavaScript(script);