[Qt-interest] Error while executing Javascript through Qt script
Kent Hansen
kent.hansen at nokia.com
Thu Mar 3 15:09:18 CET 2011
Hi,
Den 02. mars 2011 06:51, skrev ext Karthick:
> Hi All,
>
> I am trying to execute Java script code through Qt Script. While
> running that code, I was getting error like "Reference Error: can't
> find variable Google". my Java script contains code for calculating
> direction.
>
> While executing JS through HTML, JS code is included in <script
> type=text/javascript> tag.
> I don't know how to include the following javascript in Qt.
> <scripttype="text/javascript"
> src="http://maps.google.com/maps/api/js?sensor=false"></script>
> Because of this, I was getting error.
> If anyone knows, please help me to resolve this issue.
That JavaScript code relies on being executed in a browser environment;
it expects window and document objects, DOM API, and so on.
QtScript only provides the standard ECMA-262 environment.
You'll have to implement (a subset of) a browser environment in order
for that script to have any chance of working in QtScript. (For an
example of how that can be done, see the QtScript Context2D example:
http://doc.qt.nokia.com/latest/script-context2d.html)
Regards,
Kent
More information about the Qt-interest-old
mailing list