GJS: How to communicate with js inside webkit webview
- From: Rich <rl6 shinyblue net>
- To: javascript-list gnome org
- Subject: GJS: How to communicate with js inside webkit webview
- Date: Thu, 14 Mar 2013 23:08:59 +0000
Hi
I have a webkit webview, set up as in the hello tutorial[1]. I'd like to
be able to access JS inside the webview (or vice versa). e.g. I want my
GJS to allow the user to select a directory, and then to pass the
filenames into the web app.
From what I've read, I tried this
this._webView.connect('window-object-cleared', Lang.bind(this,
this.my_test));
And the docs[2] suggest that this signal should come with the window
object and the context for the JS environment inside the webview. So I
thought I could just add to this and thereby communicate with something
inside.
But my method my_test does not seem to be receiving all the parameters
it should.
e.g.
my_test:function(wv,f,c,w,u){ //web_view, frame, context,
window_object, user_data) {
c.test123 = 123;
},
gives me
JS ERROR: !!! Exception was: TypeError: c is undefined
JS ERROR: !!! lineNumber = '30'
JS ERROR: !!! fileName = '"hello.js"'
JS ERROR: !!! stack = '"([object
_private_WebKit_WebView],[object _private_WebKit_WebFr
ame],(void 0),(void 0))@hello.js:30
wrapper([object _private_WebKit_WebView],[object
_private_WebKit_WebFrame],(void 0),(void 0))@/
usr/share/gjs-1.0/lang.js:204
@hello.js:64
I'm a complete beginner to GJS and am finding it v difficult. I can't
find a way, either, to debug the thing. Even if I could write to stdout
that would help. Is Looking Glass just for extensions? Any tips most
welcome!
Thanks
Rich
[1]:
https://developer.gnome.org/gnome-devel-demos/unstable/hellognome.js.html.en
[2]:
http://webkitgtk.org/reference/webkitgtk/stable/webkitgtk-webkitwebview.html#WebKitWebView-window-object-cleared
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]