无法从 QWebView 中的 Javascript 调用 Flash (Swf) 方法
我有:
- Swf 文件,a) 通过ExternalInterface.addCallback 使其方法之一可供外部世界使用; b) 通过ExternalInterface.call调用预定义的外界方法;
- html 页面,此 Swf 文件所在的位置。该html中有两个javascipt方法:一种用于调用Swf-published-method,一种用于被swf调用;
- Qt-app,通过 QWebView->QWebPage 加载此 html 页面。
当我在 FireFox 中加载此 html 页面时,一切正常:可以从 javascript 调用 Swf,反之亦然。然而,在 Qt-app 中,只有 swf 可以调用 javascript 方法,反之则不然。调用 swf 方法失败,并在 javascript 控制台上打印以下消息:“在 NPObject 上调用方法时出错”。
有什么想法可以让 Qt-app 表现得像 FireFox 一样,即可以从 javascript 调用 Swf 吗?任何帮助将不胜感激,
背景:
- Qt 4.6.2;
- 库班图 10.04;
- Swf 是用 Flex 4 构建的;
- Swf 是本地可信的。
I have:
- Swf-file, that a) makes one of its method available to the outer world through ExternalInterface.addCallback; b) calls predefined outer world method through ExternalInterface.call;
- html-page, where this Swf-file resides. There are two javascipt methods in this html: one for calling Swf-published-method and one for being called by swf;
- Qt-app, that loads this html-page through QWebView->QWebPage.
When I load this html-page in FireFox everything works ok: Swf can be called from javascript and vice-versa. However within Qt-app only swf can call javascript method, but not vice-versa. Calling swf method fails with the following message printed on javascript console: "Error calling method on NPObject".
Any ideas how to make Qt-app behave like FireFox, i.e. to make it possible to call Swf from javascript? Any help will be appreciated,
Backgrounds:
- Qt 4.6.2;
- Kubuntu 10.04;
- Swf was built with Flex 4;
- Swf is local trusted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自己解决了问题。
加载 html 页面的原始代码如下:
重写的变体:
在后一个变体中,一切正常。
顺便说一句:在 Windows 下,第一个变体也可以工作。
Fixed problem by myself.
The original code for loading html-page was like this:
The rewritten variant:
In latter variant everything works fine.
Btw: Under Windows first variant works too.