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
Posts: 9
Registered: ‎04-13-2012
My Device: Playbook 2.0
My Carrier: CLARO BR
Accepted Solution

Second page doesn't receive arguments in HTML.

Good morning! I am developing a webworks application for Playbook, and i'm facing some problems.

 

First of all, i got this page, called index.html:

(EXAMPLE)

<html>

<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="viewport" content="initial-scale=1.0,user-scalable=no, maximum-scale=1.0, height=600, width=1024" />
<title>Index</title>
<!--Scripts-->
<script src="scripts/jquery.mobile-1.0.1.min.js"></script>

........

</head>

<body>

<a href="details.html?id=2828282&name=Collie"> Click HERE! </a>

</body>

</head>

 

 

And here's the second page, called details.html

 

<html>

<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="viewport" content="initial-scale=1.0,user-scalable=no, maximum-scale=1.0, height=600, width=1024" />
<title>Index</title>
<!--Scripts-->
<script src="scripts/jquery.mobile-1.0.1.min.js"></script>

<script language="javascript">
var qsParm = new Array();
function qs() {
alert('details');
var query = window.location.search.substring(1); // Here's the SEARCH URL, or the arguments of the page.
alert('=>' + query);
alert(query);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = i;//parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
qsParm[key] = val;
alert('aydioid' + val + ' ' + key); // Here we show the key number (i)  and its value (val) on a dialog.
}
}


}

window.onload = qs();
</script>

</head>

<body>

</body>

</head>

 

When I make a test on a web browser like Chrome, it works perfectly. But in a Playbook device, the page details.html stays all blank without showing the alerts.

 

Please someone help me!!

Thank all of you

New Contributor
Posts: 9
Registered: ‎04-13-2012
My Device: Playbook 2.0
My Carrier: CLARO BR

Re: Second page doesn't receive arguments in HTML.

Ah, i almost forgot!

 

Some observations:

 

<?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>INDEXXXXX</name>
<description>
Blabloabla <!--TODO descrição-->
</description>
<author rim:copyright="2012">ME</author> <!-- TODO author -->
<content src="index.html"/> <!-- First Page/Main Page -->
<icon src="/images/icon.png"/>
<feature id="blackberry.app"/>
<feature id="blackberry.system" version="1.0.0"/>
<feature id="blackberry.ui.dialog"/>
<access uri="*" subdomains="true"/>
<rimSmiley Surprisedrientation mode="landscape"/>
<rim:loadingScreen foregroundImage="images/splash.jpg" onFirstLaunch="true">
<rim:transitionEffect type="zoomIn" duration="500"/>
</rim:loadingScreen>
</widget>

 

that's my config.xml file. I think i am doing something wrong on javascript on the second page but i can't figure it out!

Developer
Posts: 466
Registered: ‎04-11-2012
My Device: Bold 9900
My Carrier: Rogers

Re: Second page doesn't receive arguments in HTML.

why dont u do this..

 

in index.html make button that goes

 

onclick="qs(variable)"

 

then instead of saving ur details.html... save it as a js. with just the javascript parts and then make ur function qs accept a variable

 

so like function qs (phrase){

.. 

 

theres nothing unique about page detials so this implementation would work best imo 


Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage. Please hit the like button below if what I said helped!
New Contributor
Posts: 9
Registered: ‎04-13-2012
My Device: Playbook 2.0
My Carrier: CLARO BR

Re: Second page doesn't receive arguments in HTML.

Great news ev'ryone!

 

I solved the problem just putting this on the bottom of the page, before </body> tag:

<script> window.onload = qs(); </script>

 

This prevents the function from loading before the creation of all the elements and attributes of the page... so, when the DOM tree is totally loaded, the script will run and it will encounter your element with the chosen id.

 

thanks ignites for showing another way to do this.