[Qt-interest] javascript does not load in QWebview
Karthick
sppkarthick at gmail.com
Thu Mar 10 04:48:46 CET 2011
Hi All,
I am trying to execute the javascript through evaluate javascript() call in
QWebview. while calling evaluate javacript() call in Qt, the returned value
from that call is null. how to make javascript works in Qwebview?
please help me to solve this issue?
Qt code:
QWebView *view;
view->load(QUrl("file:///home/admin/test.html"));
Qvariant name, address;
name = view->page()->mainFrame()->evaluateJavaScript("abc()");
qDebug() << name.toString(); *//getting null value*
address = view->page()->mainFrame()->evaluateJavaScript("getroute()");
qDebug() << address.toString(); *//getting null value*
test.html:
<html>
<head>
<script type="text/javascript" src="
http://maps.google.com/maps/api/js?sensor=false"></script> //This is for
calling google maps api's
<script type="text/javascript">
function *abc()*
{
*return "SUCCESS";*
}
var address; //global variable
function *getroute()*
{
/*
declaration and initialization of google maps api stuff
*/
calling *google api directionsService.route*(req, function(resp,status){
if (status == ok)
{
address = resp.routes[0].legs[0].start_address;
} });
return address;
}
</script>
<body>
</body>
</html>
--
*Regards,*
*Karthick
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110310/8cec01ad/attachment-0001.html
More information about the Qt-interest-old
mailing list