diff options
author | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-09-10 16:08:21 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-10-08 10:31:40 +0000 |
commit | 6df94b3cfd7eab7222542237a219144615bd434b (patch) | |
tree | cab61674064270d2eccc00c14a19246be2ec43ed | |
parent | a45f6fc3e1016a223a4b235cc61b033f8665c853 (diff) |
Improve runJavaScript documentation
Mention that the script will run in the same JavaScript world as scripts
that are part of the page. Also link to new scripts API.
Change-Id: I4dd80fdd84644b1fa4ce6c63ab07c1dbba855389
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
-rw-r--r-- | src/webengine/doc/src/webengineview.qdoc | 4 | ||||
-rw-r--r-- | src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc index fd7733d13..b734413ea 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 794cb56d2..173611165 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. */ /*! |