[webkit-dev] How would one call a JavaScript function from C++ using WebKit?

Boyd Timothy btimothy at gmail.com
Thu May 24 17:04:07 PDT 2007


Does anyone know what class/function I should use in WebKit to execute
a JavaScript function from C++?

I'm evaluating WebKit for use in Banter [1].  Essentially we'd like to
use the AdiumMessageStyles for our Chat Windows so you get something
more than just a plain conversation window.  The way these message
styles work is that you load some HTML (which contains some JavaScript
functions) and then as messages are sent/received, you invoke an
appendMessage() JavaScript function on the loaded web page to have the
message injected into the page.

I've modified WebKitTools/GdkLauncher/main.cpp so it loads a
Template.html file from an AdiumMessageStyle.  I tried modifying the
code so that I could call KJSProxy::evaluate(), but that doesn't seem
to do anything.

I notice there's also WebCore/html/HTMLScriptElement.h that defines
HTMLScriptElement::evaluateScript(const String &URL, const String
&script) but I'm not sure how to get hold of that object to make the
call.

Any ideas?

Thanks,

-Boyd

[1] http://live.gnome.org/Banter



More information about the webkit-dev mailing list