diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc index fd7733d13c8d298ce784454784987fb0e13abd10..b734413ea3e31942ad3ce7fd8545d61701682e26 100644 --- a/src/webengine/doc/src/webengineview.qdoc +++ b/src/webengine/doc/src/webengineview.qdoc @@ -248,6 +248,10 @@ runJavaScript("document.title", function(result) { console.log(result); }); \endcode + The script will run in the same \e world as other scripts that are + part of the loaded site. + + See WebEngineView::userScripts for an alternative API to inject scripts. */ /*! diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc index 794cb56d262ed0627f59129c450724ac601bde13..1736111657ba4caceae55f7f41c6cd9539f62aac 100644 --- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc @@ -596,16 +596,27 @@ /*! \fn void QWebEnginePage::runJavaScript(const QString& scriptSource) - Runs the JavaScript code contained in \a scriptSource. + \overload runJavaScript() + + This convenience function runs the JavaScript code contained in \a scriptSource. */ /*! \fn void QWebEnginePage::runJavaScript(const QString& scriptSource, FunctorOrLambda resultCallback) + Runs the JavaScript code contained in \a scriptSource. + The script will run in the same \e world as other scripts that are part of the loaded site. + When the script has been executed, \a resultCallback is called with the result of the last executed statement. + \a resultCallback can be any of a function pointer, a functor or a lambda, and it is expected to take a + QVariant parameter. For example: + + \code + page.runJavaScript("document.title", [](const QVariant &v) { qDebug() << v.toString(); }); + \endcode - \note \a resultCallback can be any of a function pointer, a functor or a lambda, and it is expected to take a QVariant parameter. + See scripts() for an alternative API to inject scripts. */ /*!