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
New Contributor
Lythinari
Posts: 3
Registered: ‎01-29-2011
Accepted Solution

Webworks Tablet API Examples

Im having trouble working out how to get the API functions to work in my tablet simulator.

Ive inserted the features tag into the xml file.

 

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.3" rim:header="RIM-Widget:rim/widget">
  <name>CloseMe</name>
  <description>Browser Renderer for Blackberry Playbook.</description>
  <author rim:copyright="2010">n/a</author>
  <icon rim:hover="false" src="icon.png"/>
  <icon rim:hover="true" src="icon.png"/>
  <access uri="*"/>
  <feature id="blackberry.app" required="true" version="1.0.0"/> 
  <feature id="blackberry.utils" required="true" version="1.0.0"/> 
  <content src="index.htm"/>
</widget>

 

 

And have included the script directly from the API in my code.

index.htm

 

<html>
<head>
	<meta name="viewport" content="width=device-width"/>
	<meta id="touch-event-mode" content="native"/>
	<title> Close Me </title>
	<style type="text/css">
		body { padding: 0; margin: 0; background-color: white; color: black; }
	</style>
	<script type="text/javascript">
		function close(){
			exit();
		}	
	</script>
<body>
<input type='button' onclick='close();'>

<script type="text/javascript">

  var url = blackberry.utils.parseURL("http://www.bla.com:8080/index.html?COUNTER=3&FOO=BAR");

  alert("port:"+url.port);
  alert("host:"+url.host);

  alert("parameter:"+url.getURLParameterByIndex(0));
  alert("parameter:"+url.getURLParameter("FOO"));

</script>
</body>
</html>

 

 

Ive also tried to put blackberry.app.exit();

 

but that didnt work either :smileysad:

What am I missing/doing wrong?

 

Thanks in advance, 

Lyth

 

 

Please use plain text.
Developer
ddluk
Posts: 209
Registered: ‎10-02-2010
My Carrier: Play and Plus

Re: Webworks Tablet API Examples

You missed the </head> tag. Below is working code:

<html>
<head>
	<meta name="viewport" content="width=device-width"/>
	<meta id="touch-event-mode" content="native"/>
	<title> Close Me </title>
	<style type="text/css">
		body { padding: 0; margin: 0; background-color: white; color: black; }
	</style>
	<script type="text/javascript">
function close(){
exit();
		}	

function parseurl() {

 var url = blackberry.utils.parseURL("http://www.bla.com:8080/index.html?COUNTER=3&FOO=BAR");

  alert("port:"+url.port);
  alert("host:"+url.host);

  alert("parameter:"+url.getURLParameterByIndex(0));
  alert("parameter:"+url.getURLParameter("FOO"));

};

	</script>
</head>
<body>
<input type="button" onclick="close();">
<input type="button" onclick="parseurl();">

</body>
</html>

 

 



2sky.pl - Software development is our passion.
Please use plain text.
New Contributor
Lythinari
Posts: 3
Registered: ‎01-29-2011

Re: Webworks Tablet API Examples

Gah! Thanks, I cant believe I missed that. Lyth
Please use plain text.