0

I am creating webapp using html5, css3, javascript, Phonegap in dreamweaver. I am using below code to do a goto page feature. it will open a an html page. but my problem is it's not working in android app. any help?

javascript Code

function gotopage(id){
var num = document.getElementById(id).value;

var jarry = ["pagenotfound.html","ch1/1.html","ch1/2.html","ch1/3.html","ch1/4.html","ch1/5.html","ch1/6.html"];
if(jarry[num] == null)
    num = 0;

window.location.href = window.location.pathname.substring(0,window.location.pathname.substring(1).indexOf("/"))+jarry[num];
//window.location.href = "/"+jarry[num];    

Html code

<input type="text" id="t1" size="4px"/>
<input type="button" value="Goto Page" onClick="gotopage('t1')"/>

I am getting error message on android " application error: A network error occurred. (file:///android_asset/ch1/1.html)

2 Answers2

1

Try with this.

  document.getElementById(id).innerHTML;
Amit Prajapati
  • 13,525
  • 8
  • 62
  • 84
0

It is recomended that you build your phonegap apps with just one index.html file. Instead of having multiple html pages. The reason for this is because you would have to call Cordova each time you go to a new page. This can slow things down. However it has become a tedious process to have one file with 1000's of lines of HTML code. Because of this theres the Child Browser plugin designed to allow you to navigate to pages as well as view non web based files eg PDF files and other types files from with inside of it. That being said changing the following in your code.

document.getElementById(id).value;

To

document.getElementById(id).innerHTML;
Ben P. Dorsi-Todaro
  • 221
  • 1
  • 6
  • 20