mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Scripts: Register window.external to all frames
It seems that only one QWebChannel connection per page is supported, so we need to forward window.external to all subframes.
This commit is contained in:
parent
fa2779e6b9
commit
19f1ed6bfb
@ -459,7 +459,7 @@ function init()
|
|||||||
if (window.external) {
|
if (window.external) {
|
||||||
init();
|
init();
|
||||||
} else {
|
} else {
|
||||||
document.addEventListener('qz_external_created', init);
|
document.addEventListener('_qupzilla_external_created', init);
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -25,12 +25,24 @@ QString Scripts::setupWebChannel()
|
|||||||
{
|
{
|
||||||
QString source = QL1S("(function() {"
|
QString source = QL1S("(function() {"
|
||||||
"%1"
|
"%1"
|
||||||
"new QWebChannel(qt.webChannelTransport, function(channel) {"
|
"function registerExternal(e) {"
|
||||||
" window.external = channel.objects.qz_object;"
|
" window.external = e;"
|
||||||
" if (window.external) {"
|
" if (window.external) {"
|
||||||
" var event = new Event('qz_external_created');"
|
" var event = new Event('_qupzilla_external_created');"
|
||||||
" document.dispatchEvent(event);"
|
" document.dispatchEvent(event);"
|
||||||
" }"
|
" }"
|
||||||
|
"}"
|
||||||
|
"if (self !== top) {"
|
||||||
|
" if (top.external)"
|
||||||
|
" registerExternal(top.external);"
|
||||||
|
" else"
|
||||||
|
" top.document.addEventListener('_qupzilla_external_created', function() {"
|
||||||
|
" registerExternal(top.external);"
|
||||||
|
" });"
|
||||||
|
" return;"
|
||||||
|
"}"
|
||||||
|
"new QWebChannel(qt.webChannelTransport, function(channel) {"
|
||||||
|
" registerExternal(channel.objects.qz_object);"
|
||||||
"});"
|
"});"
|
||||||
"})()");
|
"})()");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user