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: 39
Registered: ‎02-07-2012
My Device: Blackberry curve 8520 // Blackberry playbook 64GB
My Carrier: Vodafone

BB Playbook HTML5 Webworks Invoke browser from a form [NEED CODE]

i want to create a form, where people van type in a website, and it has to open that site in the BB Playbook browser..


how to code it ? 


thanks in advance ! 



Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: BB Playbook HTML5 Webworks Invoke browser from a form [NEED CODE]

[ Edited ]



Essentially you will need at least 2 files for this application.


1. config.xml (this is your application configuration file)

2. index.html (main application file)

... in this example app I have created, I seperated the code logic into app.js, and put some styles into style.css files


Please mark as solution and KUDOs. I have tested this code on a live device and it works. Thanks.






Pretty much standard. You will be using the INVOKE platform API  here. Although it's not required that you include permissions here for the Playbook, I have done so as an example.


Doc located here: https://developer.blackberry.com/html5/apis/blackberry.invoke.BrowserArguments.html

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
    <name>Go To Website</name>
    <!-- replace [your vendor name] -->
    <author>[your vendor name]</author>
    <description>A simple application to that opens a website in the browser on the the BlackBerry Playbook</description>
    <!-- uncomment below line and create app icon 86px by 86px -->
    <!--<icon src="icon.png"/>-->
    <content src="index.html"/>
    <!--whitelist all domains -->	
	<access subdomains="true" uri="*"/>
	<feature id="blackberry.invoke" required="true" version=""/>
    <feature id="blackberry.invoke.BrowserArguments" required="true" version=""/>
    <feature id="blackberry.app.event" required="true"/>



I include app.js, style.css and create an input element where user can type in a website. Logic of application is handled by app.js


<!DOCTYPE html>
    <meta id="viewport" name="viewport" content="user-scalable=no,target-densitydpi=device-dpi,initial-scale=1.0" />
    <link href="style.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="app.js"></script>
<p>Type a URL to go to the site in your BlackBerry Browser...</p>
<input type="url" id="url" /><br />
<button id="go">Take me to the internetz</button>



Three parts to this file. I include the jQuery 1.7.2 library.


1. Include jQuery library

2. Create function openBrowser() which takes one argument "url"

3. Handle button click by capturing user input using the live method


//this is jquery 1.7.2
//jquery is included in index.html

//blackberry browser invoke function
function openBrowser(url)
		var args = new blackberry.invoke.BrowserArguments(url);
		blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
	catch(e) {
		//debug.log("openBrowser", e, debug.exception);

// get user input from form

$('#go').live('click', function(){
	//get value from input
	var url = $('input').attr('value');
	//validate make sure url isn't empty
	//you probably want to actually validate that this is a url www etc
	// anyway, I will just redirect the person to what they typed to here



Make your app pretty with css(cascading style sheets) here. 
Edit this and make your app pretty.



/*your styles go here, make this app pretty*/


 That's it!


Just zip the files, package sign and deploy. If you have any other questions, let me know!

KUDOs, and accept as solution. 

Posts: 39
Registered: ‎02-07-2012
My Device: Blackberry curve 8520 // Blackberry playbook 64GB
My Carrier: Vodafone

Re: BB Playbook HTML5 Webworks Invoke browser from a form [NEED CODE]

Well, thanks for that code ! But I want to use it with this form -> <fieldset>
<legend><P STYLE="font-size: 20px; font-family: cursive;">Windows Home Server</P></legend>
<form onsubmit="window.location='http://'+this.subdomain.value+'.homeserver.com';
return false">
<P STYLE="font-size: 15px; font-family: cursive;">Http://<input type="text" name="subdomain" value="" />.homeserver.com</P>
<input type="submit" name="submit" value="Go" />

You can enter a subdomain, and you'll be redirected to that website. Can someone make this work ?

PS is it possible to get a download popup in Webworks ? (Just the feature id & permission) coding doesn't work, the website already exists

Thanks in advance ! Jeroen