fix: js unexpected error.

This commit is contained in:
xiaoyifang 2021-09-25 10:17:05 +08:00
parent d2257ce061
commit 20c3a7241d

View file

@ -531,46 +531,28 @@ void ArticleView::loadFinished( bool )
QObject* obj=sender(); QObject* obj=sender();
qDebug()<<"article view loaded url is :"<<url<<" sender class is :"<<obj->metaObject()->className(); qDebug()<<"article view loaded url is :"<<url<<" sender class is :"<<obj->metaObject()->className();
// See if we have any iframes in need of expansion // // See if we have any iframes in need of expansion
ui.definition->page()->runJavaScript(QString("var frames=windows.frames;" // ui.definition->page()->runJavaScript(QString(""
"for(int i=0;i<frames.length;i++){" //"var frames = window.frames;"
" var f=frames[i];" //"for (var i=0; i < frames.length; i++) {"
" f.height=%1;" //" var f = frames[i];"
" f.style.display='block';" //" "
"var gdLastUrlText;" //" f.onload = function()"
" f.document.addEventListener( 'click', function() { gdLastUrlText = window.event.srcElement.textContent; }, true );" //" {"
" f.document.addEventListener( 'contextmenu', function() { gdLastUrlText = window.event.srcElement.textContent; }, true );" //" f.style.height = "
//" f.contentWindow.document.body.scrollHeight + 'px';"
"}")); //" f.style.width = "
//" f.contentWindow.document.body.scrollWidth+'px'; "
//QList< QWebEnginePage * > frames = ui.definition->page()->mainFrame()->childFrames(); //" }"
//" f.style.display = 'block';"
//" var gdLastUrlText;"
//" f.document.addEventListener('click', function () { gdLastUrlText = window.event.srcElement.textContent; });"
//" f.document.addEventListener('contextmenu', function () { gdLastUrlText = window.event.srcElement.textContent; });"
//"}"
//));
bool wereFrames = false; bool wereFrames = false;
// for( QList< QWebEnginePage * >::iterator i = frames.begin(); i != frames.end(); ++i )
// {
// if ( (*i)->frameName().startsWith( "gdexpandframe-" ) )
// {
// //DPRINTF( "Name: %s\n", (*i)->frameName().toUtf8().data() );
// //DPRINTF( "Size: %d\n", (*i)->contentsSize().height() );
// //DPRINTF( ">>>>>>>>Height = %s\n", (*i)->runJavaScript( "document.body.offsetHeight;" ).toString().toUtf8().data() );
// // Set the height
// ui.definition->page()->runJavaScript( QString( "document.getElementById('%1').height = %2;" ).
// arg( (*i)->frameName() ).
// arg( (*i)->contentsSize().height() ) );
// // Show it
// ui.definition->page()->runJavaScript( QString( "document.getElementById('%1').style.display = 'block';" ).
// arg( (*i)->frameName() ) );
// (*i)->runJavaScript( "var gdLastUrlText;" );
// (*i)->runJavaScript( "document.addEventListener( 'click', function() { gdLastUrlText = window.event.srcElement.textContent; }, true );" );
// (*i)->runJavaScript( "document.addEventListener( 'contextmenu', function() { gdLastUrlText = window.event.srcElement.textContent; }, true );" );
// wereFrames = true;
// }
// }
//todo //todo
if ( wereFrames ) if ( wereFrames )