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
Contributor
thinkkevin
Posts: 10
Registered: ‎07-31-2012
My Device: PlayBook
My Carrier: CMCC
Accepted Solution

Any way to show back/forward menu item?

I'm just wrapping a mobile web link into a tablet app. So basically, the app shows the web URL page defined in config.xml. I want to add naviagation menu item like back and forward button, anyone knows how to do it?

 

Any way I could write some codes to make it just like a simple browser which links to a URL by default?

Thanks!

 

Kevin

Please use plain text.
Developer
scrid2000
Posts: 142
Registered: ‎07-27-2011
My Device: Red Z10, 32GB PlayBook, Numerous Android/WP8/FirefoxOS/Other devices
My Carrier: T-Mobile

Re: Any way to show back/forward menu item?

You can have links or buttons using the following code:

Forward:

href="javascript:history.go(-1)">


Back:

href="javascript:history.go(1)"

 

You can use onclick="" as well if you'd prefer.

-----------------------------------------------------------------------------------------



Please use plain text.
Contributor
thinkkevin
Posts: 10
Registered: ‎07-31-2012
My Device: PlayBook
My Carrier: CMCC

Re: Any way to show back/forward menu item?

Thanks for your reply. But it seems not what I want.

I couldn't modify the URL page I specify in the content:src element in config.xml. So I wonder if there is some tricky ways to do so.
Please use plain text.
Developer
scrid2000
Posts: 142
Registered: ‎07-27-2011
My Device: Red Z10, 32GB PlayBook, Numerous Android/WP8/FirefoxOS/Other devices
My Carrier: T-Mobile

Re: Any way to show back/forward menu item?

Webworks doesn't give any good way to include an external Page that I'm aware of.

You might be able to use an iframe or embed the mobile webpage, and include navigation as well. However, the site owner could very easily block that (and may already have done so).

You can use child.browser, but it will not be BB10 compatible because it's based on flash.

 

Is the webpage static? The best option would be to simple include the HTML and js files within the app.

-----------------------------------------------------------------------------------------



Please use plain text.
Contributor
thinkkevin
Posts: 10
Registered: ‎07-31-2012
My Device: PlayBook
My Carrier: CMCC

Re: Any way to show back/forward menu item?

The web page is HTML5 style page, and it works well within itself. But it has some links point to other site. After user clicks this kind of link, he could not get back again. That's my pain.
Please use plain text.
Developer
scrid2000
Posts: 142
Registered: ‎07-27-2011
My Device: Red Z10, 32GB PlayBook, Numerous Android/WP8/FirefoxOS/Other devices
My Carrier: T-Mobile

Re: Any way to show back/forward menu item?

That's easy then :smileyhappy: package the site as an app, and set up the links to invoke the browser.
-----------------------------------------------------------------------------------------



Please use plain text.
Contributor
thinkkevin
Posts: 10
Registered: ‎07-31-2012
My Device: PlayBook
My Carrier: CMCC

Re: Any way to show back/forward menu item?

Nice to talk with you. So how to make the links to invoke browser?
Please use plain text.
Developer
scrid2000
Posts: 142
Registered: ‎07-27-2011
My Device: Red Z10, 32GB PlayBook, Numerous Android/WP8/FirefoxOS/Other devices
My Carrier: T-Mobile

Re: Any way to show back/forward menu item?

[ Edited ]

Instructions are at https://developer.blackberry.com/html5/apis/blackberry.invoke.html

It looks as if the API just changed (I haven't tested the new function) but you have a javascript command that you call with onclick.

 

Untested (by me) sample:

 

function openWebLinkInBrowser() {
    // open web link in browser
    blackberry.invoke.invoke({
        target: "sys.browser",
        uri: "http://www.blackberry.com"
    });
}
<img src="image.png" onclick="openWebLinkInBrowser()" />
-----------------------------------------------------------------------------------------



Please use plain text.
Contributor
thinkkevin
Posts: 10
Registered: ‎07-31-2012
My Device: PlayBook
My Carrier: CMCC

Re: Any way to show back/forward menu item?

Great!

Thanks very much for your help!
Please use plain text.