最初使用 BrowserField 加载页面,然后单击链接在 BB 浏览器而不是 BrowserField 中打开?
我想首先使用 BrowserField 加载一个页面(存储的 html 页面),然后单击在 BB 浏览器而不是 BrowserField 中打开的链接?
我当前的代码如下,
BrowserFieldConfig.setProperty(BrowserFieldConfig.CONTROLLER, new BrowserFieldController()
{
public InputConnection handleResourceRequest(BrowserFieldRequest request) throws Exception {
return (InputConnection)Connector.open(request.getURL());
}
public void handleNavigationRequest(BrowserFieldRequest request) throws Exception
{
BrowserSession b = Browser.getDefaultSession();
b.displayPage(request.getURL());
}
});
我想加载存储在 browserfield 资源中的 html 页面,然后打开我正在使用的 BB 浏览器中页面的链接 browserfield.requestContent("local:///test.html");
但应用程序尝试在浏览器中打开 html 文件,这是不可取的。
请给我建议一个解决方法,
谢谢, 阿尼凯特
I want to initially load a page (stored html page) with the BrowserField and then have links clicked in that open up in the BB browser instead of the BrowserField?
My current code is as following,
BrowserFieldConfig.setProperty(BrowserFieldConfig.CONTROLLER, new BrowserFieldController()
{
public InputConnection handleResourceRequest(BrowserFieldRequest request) throws Exception {
return (InputConnection)Connector.open(request.getURL());
}
public void handleNavigationRequest(BrowserFieldRequest request) throws Exception
{
BrowserSession b = Browser.getDefaultSession();
b.displayPage(request.getURL());
}
});
And I want to load the html page stored in resources in browserfield and then open the links from the page in BB Browser which I'm doing using
browserfield.requestContent("local:///test.html");
But application tries to open the html file in browser, which is not desirable.
Please suggest me a workaround,
Thanks,
Aniket
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该很容易实现。
This should be quite easy to achieve.
每次 browserfield 请求内容时都会调用 handleNavigationRequest(BrowserFieldRequest request) 方法。
在方法内添加计数。
每次调用该方法时,计数加 1。
如果计数大于 0,则表示 Browserfield 已经第一次加载。对该方法的后续调用应该打开浏览器会话,而不是请求 Browserfield 内的内容。
The handleNavigationRequest(BrowserFieldRequest request) method is called each time the browserfield requests content.
Add a count inside the method.
Increment the count by 1 each time the method is called.
If the count is greater then 0, it means the Browserfield has already loaded the first time. Subsequent calls to the method should then open a browser session instead of requesting content inside the Browserfield.