04-13-2012 09:42 AM
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
Solved! Go to Solution.
04-13-2012 09:45 AM
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"/>
<rim
rientation 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!
04-13-2012 11:36 AM
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
04-13-2012 12:44 PM
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.