如何加载在codeNAME一个WebBrowser组件外部URL? [英] How to load an external url in Codename One WebBrowser component?

查看:288
本文介绍了如何加载在codeNAME一个WebBrowser组件外部URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我?我在开发有一个App和核心功能是加载第三方网页(URL),有CSS和JavaScript在codeNAME一个WebBrowser组件。我的问题是: -
1.如何加载的网址?
2.是否有可能与这个网址类似的警报并确认JavaScript的互动?
3.如何使设备的默认浏览器等之间切换?

Can anyone help me? I've got an App in development and a core feature is to load a third party webpage (URL) that has css and javascript in the Codename One WebBrowser component. My questions are:- 1. How do I load the url? 2. Is it possible to interact with the javascript on this url like alerts and confirms? 3. How to switch between Device default browser etc?

感谢。

推荐答案

一个本地WebBrowser组件是奠定了一个-同步,这意味着它的preferred大小后计算,所以用一个0,0大小的布局它的地方。在RIM我们默认使用传统HTMLComponent(从J2ME),因为RIM的原生浏览器组件是片状的,这就是为什么RIM的版本为你工作,而Android版本没有。

A native WebBrowser component is laid out a-synchronously which means its preferred size is calculated later and so the layout places it with a 0,0 size. On RIM we default to using the legacy HTMLComponent (from J2ME) since RIM's native browser component is flaky, that is why the RIM version works for you while the Android version does not.

该HTMLComponent仅支持HTML / CSS的一个子集,不支持任何JavaScript所以这可能不是你想用什么。您可以启用本地RIM浏览器组件(虽然它是片状的,有许多已知问题没有解决方法)通过设置参数编译:rim.nativeBrowser = TRUE

The HTMLComponent supports only a subset of HTML/CSS and doesn't support any JavaScript so this is probably not what you would want to use. You can enable the native RIM browser component (although it is flaky and has many known issues with no workaround) by setting the build argument: rim.nativeBrowser=true

您可以在codeNAME一个项目属性设置这些参数,它是否适合你再伟大的。

You can set these arguments in the project properties for Codename One, if it works for you then great.

要解决放置例如浏览器时,你可以使用像BorderLayout的布局的布局问题:

To fix the layout issue you can use a layout like BorderLayout when placing the browser e.g.:

form.setLayout(new BorderLayout());
form.addComponent(BorderLayout.CENTER, browser);

这将伸展在屏幕上忽视了其preferred大小的组件。另外,您可以跟踪浏览器事件,并重新验证或硬code一preferred大小值(我不推荐)。

This will stretch the component over the screen ignoring its preferred size. Alternatively you can track browser events and revalidate or hardcode a preferred size value (which I wouldn't recommend).

这篇关于如何加载在codeNAME一个WebBrowser组件外部URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆