Manages a collection of user scripts. 更多...
import 语句: | import QtWebEngine |
Since: | QtWebEngine 6.2 |
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
WebEngineScriptCollection handles a user scripts collection, which is injected in the JavaScript engine during the loading of web content.
使用 WebEgineView.userScripts and WebEngineProfile.userScripts to access the collection of scripts associated with a single page or number of pages sharing the same profile.
The collection of user script objects in QML can be created for a set of user script objects by simple assignment to WebEngineScriptCollection.collection property or by WebEngineScriptCollection methods.
注意: The new user script can be instantiated with JavaScript dictionaries when using collection 特性。
See the following code snippets demonstrating the usage:
var scriptFoo = { name: "Foo", sourceUrl: Qt.resolvedUrl("foo.js"), injectionPoint: WebEngineScript.DocumentReady } webEngineView.userScripts.collection = [ scriptFoo, scriptBar ];
var script = WebEngine.script() script.name = "FOO" webEngineView.userScripts.collection = [ script ]
var script = WebEngine.script() script.name = "FOO" webEngineView.userScripts.insert(script) var list = [ script ] webEngineView.userScripts.insert(list)
另请参阅 WebEngineScript and WebEngineScriptCollection .
collection
:
list
<
WebEngineScript
>
|
This property holds a JavaScript array of user script objects. The array can take WebEngineScript basic type or a JavaScript dictionary as values.
This property was introduced in QtWebEngine 6.2.
|
Removes all script objects from this collection.
This method was introduced in QtWebEngine 6.2.
|
Checks if the specified script is in the collection.
This method was introduced in QtWebEngine 6.2.
另请参阅 find ().
|
Returns a list of all user script objects with the given name .
This method was introduced in QtWebEngine 6.2.
另请参阅 find().
|
Inserts a single script 进集合。
This method was introduced in QtWebEngine 6.2.
另请参阅 find ().
|
插入 list of WebEngineScript values into the user script collection.
This method was introduced in QtWebEngine 6.2.
另请参阅 find ().
|
返回
true
if a given
script
is removed from the collection.
This method was introduced in QtWebEngine 6.2.
另请参阅 insert ().