[webkit-gtk] window.webkit undefined?

Michael Catanzaro mcatanzaro at redhat.com
Wed Jan 25 10:07:27 PST 2023


On Wed, Jan 25 2023 at 06:37:11 PM +0100, Antonio <antonio at vieiro.net> 
wrote:
> The fact is that I'm trying to receive messages from a <script> in my 
> webpage through the "window.webkit.messageHandlers.XYZ.postMessage()" 
> call, as indicated in [1], but "window.webkit" is undefined.

I think it's only going to be defined for JS executed via WebKit API, 
not for JS that's defined by your web content? Otherwise random web 
content would be able to talk to your internal message handlers, and 
that's probably not good.

Try webkit_web_view_run_javascript() in the UI process, or 
jsc_value_object_invoke_method() in the web process.

Michael




More information about the webkit-gtk mailing list