1.js undefined error

2,disable chrome auto play feature
This commit is contained in:
xiaoyifang 2021-09-22 11:20:42 +08:00
parent 4a5af10277
commit 17afc21478
3 changed files with 3 additions and 9 deletions

View file

@ -185,7 +185,7 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word,
"el=document.getElementById( gdCurrentArticle ); el.className = el.className.replace(' gdactivearticle','');" "el=document.getElementById( gdCurrentArticle ); el.className = el.className.replace(' gdactivearticle','');"
"el=document.getElementById( 'gdfrom-' + newId ); el.className = el.className + ' gdactivearticle';" "el=document.getElementById( 'gdfrom-' + newId ); el.className = el.className + ' gdactivearticle';"
"gdCurrentArticle = 'gdfrom-' + newId; gdAudioLinks.current = newId;" "gdCurrentArticle = 'gdfrom-' + newId; gdAudioLinks.current = newId;"
"articleview.onJsActiveArticleChanged(gdCurrentArticle); } }" " } }"
"var overIframeId = null;" "var overIframeId = null;"
"function gdSelectArticle( id ) {" "function gdSelectArticle( id ) {"
"var selection = window.getSelection(); var range = document.createRange();" "var selection = window.getSelection(); var range = document.createRange();"
@ -630,13 +630,6 @@ void ArticleRequest::bodyFinished()
{ {
head += "</div></div><div style=\"clear:both;\"></div><span class=\"gdarticleseparator\"></span>"; head += "</div></div><div style=\"clear:both;\"></div><span class=\"gdarticleseparator\"></span>";
} }
else
{
// This is the first article
head += "<script type=\"text/javascript\">"
"var gdCurrentArticle=\"" + gdFrom + "\"; "
"articleview.onJsActiveArticleChanged(gdCurrentArticle)</script>";
}
bool collapse = false; bool collapse = false;
if( articleSizeLimit >= 0 ) if( articleSizeLimit >= 0 )

View file

@ -272,7 +272,6 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm,
connect( ui.definition, SIGNAL( loadFinished( bool ) ), connect( ui.definition, SIGNAL( loadFinished( bool ) ),
this, SLOT( loadFinished( bool ) ) ); this, SLOT( loadFinished( bool ) ) );
attachToJavaScript();
// connect( ui.definition->page(), SIGNAL( javaScriptWindowObjectCleared() ), // connect( ui.definition->page(), SIGNAL( javaScriptWindowObjectCleared() ),
// this, SLOT( attachToJavaScript() ) ); // this, SLOT( attachToJavaScript() ) );
@ -753,6 +752,7 @@ void ArticleView::setCurrentArticle( QString const & id, bool moveToIt )
"}").arg(articleId).arg(moveToIt).arg(id); "}").arg(articleId).arg(moveToIt).arg(id);
ui.definition->page()->runJavaScript(script); ui.definition->page()->runJavaScript(script);
onJsActiveArticleChanged(id);
// if ( getArticlesList().contains( id.mid( 7 ) ) ) // if ( getArticlesList().contains( id.mid( 7 ) ) )
// { // {

View file

@ -1301,6 +1301,7 @@ void MainWindow::applyWebSettings()
{ {
QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings(); QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings();
defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins); defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins);
defaultSettings->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, false);
//defaultSettings->setAttribute( QWebEngineSettings::DeveloperExtrasEnabled, true ); //defaultSettings->setAttribute( QWebEngineSettings::DeveloperExtrasEnabled, true );
} }