无法从 QWebView 中的 Javascript 调用 Flash (Swf) 方法

发布于 2024-09-14 05:57:22 字数 639 浏览 1 评论 0原文

我有:

  • 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情泪▽动烟 2024-09-21 05:57:22

自己解决了问题。

加载 html 页面的原始代码如下:

QFile html(<theHtmlPageFileName>);

html.open(QIODevice::ReadOnly);

m_page->mainFrame()->setContent(html.readAll());

重写的变体:

m_page->mainFrame()->load(<theHtmlPageFileName>);

在后一个变体中,一切正常。

顺便说一句:在 Windows 下,第一个变体也可以工作。

Fixed problem by myself.

The original code for loading html-page was like this:

QFile html(<theHtmlPageFileName>);

html.open(QIODevice::ReadOnly);

m_page->mainFrame()->setContent(html.readAll());

The rewritten variant:

m_page->mainFrame()->load(<theHtmlPageFileName>);

In latter variant everything works fine.

Btw: Under Windows first variant works too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文