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

Posts: 10
Registered: ‎03-03-2011
My Device: Z10 / Dev Alpha C / PlayBook

[PlayBook WebWorks SDK] Invoking Browser: Doesn't work with arguments!?

Hi all!


When I open an instance of the PlayBook browser app (from my WebWorks app) to show a webpage, it can happen two things:

- If it's just a domain or a domain plus a file, it works fine (not for HTTPS, though, which throws an exception).

- But, if you add parameters ("?q=example"), for instance, it does a mess with them. 


I've tried to encode the URL, that way I get the complete URL (parameters included) passed to the browser, but it's never decoded and, thus, useless.


Is it a bug, am I doing something wrong?






try {

 var args = new blackberry.invoke.BrowserArguments(url);

  blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);

 } catch(e) {

 alert("Exception: " + e);



Of course, I've added the corresponding features to the config.xml:

<feature id="blackberry.invoke" version="1.0.0"/> 
<feature id="blackberry.invoke.BrowserArguments" version="1.0.0"/> 
<feature id="blackberry.identity" version="1.0.0"/> 

New Contributor
Posts: 4
Registered: ‎05-27-2011
My Device: PlayBook

Re: [PlayBook WebWorks SDK] Invoking Browser: Doesn't work with arguments!?

Hello martihs,


To fix your problem, you can include this method in your script and simply use it to invoke the browser:



// Method to follow links in BlackBerry Browser
function followLink(address) {
	var encodedAddress = "";
	// URL Encode all instances of ':' in the address
	encodedAddress = address.replace(/:/g, "%3A");
	// Leave the first instance of ':' in its normal form
	encodedAddress = encodedAddress.replace(/%3A/, ":");
	// Escape all instances of '&' in the address
	encodedAddress = encodedAddress.replace(/&/g, "\&");
	if (typeof blackberry !== 'undefined') {
			// If I am a BlackBerry device, invoke native browser
			var args = new blackberry.invoke.BrowserArguments(encodedAddress);
			blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
		} catch(e) {
 			alert("Sorry, there was a problem invoking the browser");
	} else {
		// If I am not a BlackBerry device, open link in current browser
		window.location = encodedAddress; 

 Now, if you want the whole explanation, here goes...


This all started because we wanted to share links through social networks (Facebook, Twitter, etc) and realized that it was not possible in WebWorks (oAuth) - but I won't go into that now.


We decided to use the basic 'share' links that these networks offer but to our surprise, there was no apparent way to invoke the PlayBook's browser with addresses that had parameters. After much trial and error, we noticed that if we escaped the ampersands in a link (backslash \ ), it worked sometimes. Then we noticed other problematic characters like the colon ':' and found that if we URL encode them - it works. The funny (not) part was that if the whole address is URL encoded, then it does not work either.


So to summarize, here is what the code above does:

- Receive an address (string)

- URL encode all colons ':' starting after the first one

- Escape '\' all ampersands in the address

IF in a BlackBerry device -> invoke the native browser

else -> follow the link in the current browser (works when testing app on Desktops (Chrome, Firefox, etc)


Hope this helps!


- AJ

Trusted Contributor
Posts: 103
Registered: ‎03-31-2011
My Device: Curve 9330

Re: [PlayBook WebWorks SDK] Invoking Browser: Doesn't work with arguments!?



So what you just call followLink() in your body onload method to see if a link was called or do you have to specify the link?

Regular Visitor
Posts: 1
Registered: ‎02-04-2013
My Device: BB10 Dev beta

Re: [PlayBook WebWorks SDK] Invoking Browser: Doesn't work with arguments!?

I've added to config.xml needed features for browser invocation, but when trying to create an instance of blackberry.invoke.BrowserArguments I get an error: blackberry.invoke.BrowserArguments is undefined.


In debug session it is definitely 'undefined'. What am I doing wrong?


I'm using BB10 Dev Beta device


<feature id="blackberry.app" />
<feature id="blackberry.io" />
<feature id="blackberry.invoke.card" />
<feature id="blackberry.invoke" />
<feature id="blackberry.invoke.MessageArguments" />
<feature id="blackberry.invoke.BrowserArguments" />
<feature id="blackberry.message" />
<feature id="blackberry.identity" />
<feature id="blackberry.bbm.platform" />
<feature id="blackberry.ui.cover" />