1

Is it possible to replace the url in the childbrowser with a database variable? The database variable is a url in the database. For example, in the code below res[i].showlink is a database variable that is a url. The child browser works perfectly if I replace the database variable with http://www.google.com. I also know that my database call is pulling the urls correctly with "res[i].showlink". However, when I put in the database variable, the child browser displays a blank screen and reads as loading. I am working with phonegap in Xcode.

function openGoogle(){ 
var root = this; 
cb = window.plugins.childBrowser;  
cb.showWebPage("res[i].showlink"); 
}

If I remove the quotes around the res[i].showlink, then nothing happens when I click on the link. If I put the quotes back on, the childbrowser loads as if it is going to work but the browser remains blank. The childbrowser does seem to be able to determine that the url links from the database are different. If the link is going to google then the childbrowser will display a blank screen and the loading bar will output "about:blank". If the url link is going to a pdf file then the childbrowser will also be blank but the loading bar will actually output "Loading". Weird.

Here is what the Xcode output console displays when I click on a link with the quotes on the res[i].showlink.

2012-07-09 08:01:25.549 MyAppTest[13067:13403] View did load

2012-07-09 08:01:25.551 MyAppTest[13067:13403] Opening Url : res[i].showlink

The output console does not display anything if the quotes are not around the res[i].showlink

Any help will be greatly appreciated! Thank you

stat8
  • 689
  • 1
  • 6
  • 10

1 Answers1

0

You need to remove the quotes. Use:

cb.showWebPage(res[i].showlink); 
Simon MacDonald
  • 23,253
  • 5
  • 58
  • 74
  • I tried removing the comments but I think the problem has to do with my database variable. I am using json to parse the database variable. After the code below runs, I lose my res[i].showlink database variable. I think it has to do with the fact that the database variable is in json but I am attempting to place it into a javascript function. Any suggestions? – stat8 Jul 09 '12 at 17:57
  • $.get("http://www.databasecall=json", {}, function(res) { $.mobile.hidePageLoadingMsg(); if(res.length){ var s = ""; for(var i=0; i" + res[i].showlink + ""; }} $("#showList").html(s); $("#showList").listview("refresh"); },"json"); – stat8 Jul 09 '12 at 18:02