Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
FloPMT
Posts: 160
Registered: ‎03-12-2011
My Device: PlayBook♥
Accepted Solution

Open link in Browser

Hey guys

I've done this for playbook before but I guess it changed with bb10:
How do I open a link in the browser?
So from the webworks app, click on a link and some JavaScript then opens a link in the browser.

Please let me know
Thank you :-)
----------
Please give free Likes if I helped you out! :smileyhappy:
Contributor
Gerii
Posts: 33
Registered: ‎04-30-2012
My Device: PlayBook, DevAlpha

Re: Open link in Browser

You can use window.open("www.blackberry.com", "_blank"); to open the link in a card above your app or you can open the browser in a new window with the invoke framework:

function openWebLink() { // open web link - allows the system to choose an appropriate target that handles http:// blackberry.invoke.invoke({ uri: "http://www.blackberry.com" }, onInvokeSuccess, onInvokeError); } function openWebLinkInBrowser() { // open web link in browser blackberry.invoke.invoke({ target: "sys.browser", uri: "http://www.blackberry.com" }, onInvokeSuccess, onInvokeError); }
BlackBerry Development Advisor
chadtatro
Posts: 620
Registered: ‎10-01-2009
My Device: Z10

Re: Open link in Browser

Hello,  you can do it this way as well.

 

https://developer.blackberry.com/html5/apis/blackberry.invoke.html#.invoke

 

function openWebLinkInBrowser() {

    // open web link in browser

    blackberry.invoke.invoke({

        target: "sys.browser",

        uri: "http://www.blackberry.com"

    }, onInvokeSuccess, onInvokeError);

}

 

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Developer
FloPMT
Posts: 160
Registered: ‎03-12-2011
My Device: PlayBook♥

Re: Open link in Browser

[ Edited ]

Thank you. Something's still missing. It does not open the page and does not show an error message.

Dev Alpha A is updated and the SDK as well.


Here's my javascript:

function test()
{
blackberry.invoke.invoke({
target: "sys.browser",
uri:"http://www.google.com"
}, onInvokeSuccess, onInvokeError);
}

function onInvokeSuccess() {
alert("Invocation successful!");
}

function onInvokeError(error) {
alert("Invocation failed, error: " + error);
}


And here's my Config.xml:
<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.0" id="com.xxxxx.xxxx">

<name>xxxx</name>
<description>xxxx</description>
<versionNumber>1.0.0.0</versionNumber>
<content src="index.html"/>
<author rim:copyright="2012" email="xxxx@googlemail.com">xxxxxx</author>
<icon rim:hover="false" src="icon.jpg"/>
<icon rim:hover="true" src="icon.jpg"/>
<rim:splash src="launch.jpg"/>
<feature id="blackberry.app.orientation">
<param name="mode" value="portrait" />
</feature>
<feature id="blackberry.invoke" />
</widget>

----------
Please give free Likes if I helped you out! :smileyhappy:
Developer
FloPMT
Posts: 160
Registered: ‎03-12-2011
My Device: PlayBook♥

Re: Open link in Browser

Anybody who know's what's wrong?
----------
Please give free Likes if I helped you out! :smileyhappy:
BlackBerry Development Advisor
chadtatro
Posts: 620
Registered: ‎10-01-2009
My Device: Z10

Re: Open link in Browser

Can you try installing this Invoker sample app from our GitHub repo?

 

https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/invoke

 

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Developer
FloPMT
Posts: 160
Registered: ‎03-12-2011
My Device: PlayBook♥

Re: Open link in Browser

I had to include the current webworks.js .. I never had to on Tablet OS, sorry.
Thanks for your help guys!
----------
Please give free Likes if I helped you out! :smileyhappy: