[webkit-dev] stringByEvaluatingJavaScriptFromString: OSX & Windows

Michael Goddard michael.goddard at trolltech.com
Mon Sep 29 20:34:51 PDT 2008


On Monday 22 September 2008 13:57, Jason Hullinger wrote:

> That function is not exported by the WebKit DLL, so there is no direct way
> to GetProcAddress for the method name. Would anyone know what the best
> approach would be to compile WebKit in order to generate the libs to build
> my own program that could call that function? In other words, would
> compiling under Qt, Cygwin or VC++ be better for this, or would any way
> allow me to do what I need? I ask because I'm having a very difficult time
> compiling for Windows and would like to concentrate on the best approach.

You may be able to use the QtWebkit port on your platforms, and use the

QVariant QWebFrame::evaluateJavaScript(const QString& source)

method to do something similar to the ObjC function above.  e.g:

QWebPage myPage;
QWebFrame *myFrame = myPage->mainFrame();
myFrame->setHtml("<html><form><input id='myInputElement' value='Default 
value'></html>");
QString value;

// returns "Default value":
value = myFrame->evaluateJavaScript("myInputElement.value").toString();

myFrame->evaluateJavaScript("myInputElement.value='New value');
// returns "New value":
value = myFrame->evaluateJavaScript("myInputElement.value").toString();

// returns "hello":
value = myFrame->evaluateJavaScript("function hello(){ return 'hello'; } 
hello();").toString();

Of course, how this might integrate with your existing (ObjC?) code is another 
question :)

Some links that might help:

http://doc.trolltech.com/4.4/qtwebkit.html
http://doc.trolltech.com/4.4/qwebframe.html
http://trac.webkit.org/wiki/QtWebKit

Cheers,
MichaelG


More information about the webkit-dev mailing list