0

我有一个 JavaFx 2.0 Web 应用程序,其中有一个显示 twitter 小部件的 Webview 组件。

当应用程序在浏览器中加载时,它不会显示 Twitter 框。

它仅适用于桌面,当我从桌面启动应用程序时一切正常。

这是小部件的代码:

更新:我在应用程序中有另一个 WebView 组件,它工作正常,它在本地引用了一个 .js 文件。我决定下载其他 javascript 的源代码并在本地引用它。它没有用。

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
    <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>templates</title>
<meta name="author" content="Artur Vieira" />
<!-- Date: 2011-12-13 -->
    </head>
    <body>
    <div class="twitter"><script type="text/javascript" src="widget.js" language="javascript"></script> <script>
                    new TWTR.Widget({
                     version: 2,
                     type: 'search',
                     search: 'Nestroia',
                     interval: 6000,
                     title: 'Nestroia on Twitter',
                     subject: 'Follow Us on Twitter',
                     width: 80,
                     height: 250,
                     theme: {
                       shell: {
                         background: '#5584a3',
                         color: '#fff'
                       },
                       tweets: {
                         background: '#fff',
                         color: '#696966',
                         links: '#000'
                       }
                     },
                     features: {
                       scrollbar: false,
                       loop: true,
                       live: true,
                       hashtags: true,
                       timestamp: true,
                       avatars: true,
                       behavior: 'default'
                     }
                    }).render().start();
                </script>

            </div>
    </body>
    </html>

这是 JavaFX 2.0 Web 应用程序中 WebView 的代码

    Group block4 = new Group();
    block4.setLayoutX(740);
    block4.setLayoutY(180);
    WebView webTwitter = new WebView();
    webTwitter.setMinSize(158, 390);
    webTwitter.setPrefSize(158, 390);
    final WebEngine eng2 = webTwitter.getEngine();
    eng2.load("http://www.nestroia.com/twitter.html");

任何帮助是极大的赞赏。

4

1 回答 1

0

我相信您的问题是 jnlp/plugin 应用程序正在沙盒中运行并且具有安全限制。访问另一个域属于未签名应用程序的安全违规行为。请参阅http://docs.oracle.com/javase/tutorial/security/tour1/index.html

为了避免沙盒,您可以签署您的应用程序:

如果这没有帮助,请为浏览器启用 Java 控制台并向我们显示输出: Control Panel->Java->Advanced->Java Console->Show Console

于 2011-12-14T10:13:47.470 回答