[webkit-gtk] Proper way to load javascript

Daniel Berek berekdaniel at gmail.com
Tue Mar 5 13:30:04 PST 2019


Thanks, loading scripts with  webkit_user_content_manager_add_script() works,
but it seems like cannot hold values for global javascript variables. Did
somebody experienced this issue? Thanks

Adrian Perez de Castro <aperez at igalia.com> ezt írta (időpont: 2019. márc.
5., K, 15:42):

> Hello Daniel,
>
> On Tue, 5 Mar 2019 14:22:23 +0100, Daniel Berek <berekdaniel at gmail.com>
> wrote:
>
> > Hi, one more question, u mentioned that at the and I have to use the
> > “user-content-manager” property [3].
> > Do you have any examples or tutorials for that, or is my implementation
> > enough?
> >
> > WebKitUserContentManager *manager =
> > webkit_web_view_get_user_content_manager(*this);
> > g_signal_connect(manager,
> > "script-message-received::buttonPressed",
> > G_CALLBACK(button_pressed_received_cb),
> > this);
> > WebKitUserScript* script =
> > webkit_user_script_new("file:///home/pi/gui/script.js",
> > WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
> > WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_END, nullptr, nullptr);
> > webkit_user_content_manager_add_script(manager, script);
> > webkit_user_script_unref(script);
>
> Yes, using the WebKitUserContentManager that is created by default, which
> you are obtaining with “webkit_web_view_get_user_content_manager()” in your
> sample code 👍
>
> Cheers,
>
>
> -Adrián
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-gtk/attachments/20190305/e48ea09c/attachment.html>


More information about the webkit-gtk mailing list