【发布时间】:2013-08-19 18:48:34
【问题描述】:
我在 Dreamweaver 中使用 html5、css3、javascript、Phonegap 创建 webapp。 我正在使用下面的代码来执行转到页面功能。它将打开一个 html 页面。但我的问题是它在android应用程序中不起作用。有什么帮助吗?
javascript代码
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代码
<input type="text" id="t1" size="4px"/>
<input type="button" value="Goto Page" onClick="gotopage('t1')"/>
我在 android 上收到错误消息“应用程序错误:发生网络错误。(file:///android_asset/ch1/1.html)
【问题讨论】:
-
看起来
window.location.pathname不像你想象的那样
标签: javascript cordova goto android-assets