我需要帮助在 JavaFx 2.0 Web 应用程序中的 WebView 中部署 javascript

发布于 2024-12-21 00:05:19 字数 2438 浏览 1 评论 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");

非常感谢任何帮助。

I have a JavaFx 2.0 web application in which there is a Webview component that displays a twitter widget.

When the Application loads in the browser it doesn't show the twitter box.

It only works from the desktop, when I launch the app from the desktop all is well.

Here is the code for the widget:

Update: I had another WebView component in the application and it is working fine, it referenced a .js file locally. I decided to download the source for the other javascript and reference it locally. It didn't work.

    <!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>

Here is the code for the WebView inside the JavaFX 2.0 web application

    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");

Any help is greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

和我恋爱吧 2024-12-28 00:05:19

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

要避免沙箱,您可以对您的应用程序进行签名:

如果这没有帮助,请启用浏览器的 Java 控制台并向我们显示输出:
控制面板->Java->高级->Java控制台->显示控制台

I believe your problem is that jnlp/plugin applications are being run in Sandbox and has security limitations. And accessing another domain falls under security violation for unsigned apps. See http://docs.oracle.com/javase/tutorial/security/tour1/index.html

To avoid Sandbox you can sign your application:

If this doesn't help, please, enable Java Console for browser and show us the output:
Control Panel->Java->Advanced->Java Console->Show Console

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