【问题标题】:phonegap android: opening another html file in the phonegap webviewphonegap android:在phonegap webview中打开另一个html文件
【发布时间】:2012-02-04 06:44:54
【问题描述】:

我正在构建一个 phonegap(v1.3) android(for 3.1 sdk) 应用程序。我在示例应用程序中加载 index.html 页面

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setIntegerProperty("loadUrlTimeoutValue", 60000);
    super.loadUrl("file:///android_asset/www/index.html"); 
}

这很好用。现在稍后,当我通过插件从 js 调用它时,我想在 webview 中加载另一个 abc.html 文件。 如何实现这样的功能,我们可以从 Phonegap 插件中调用。

public void loadUrl(String file){
     super.setIntegerProperty("loadUrlTimeoutValue", 60000);
     super.loadUrl("file:///android_asset/www/"+file+".html");   
}

如果不是这样,如何在phonegap webview中加载另一个html?

【问题讨论】:

    标签: android cordova phonegap-plugins


    【解决方案1】:

    一个简单的

    window.location.href = "file.html";
    

    就是这样。 :(

    【讨论】:

    • 虽然如果 file.html 调用 PhoneGap API,你需要使用 ChildBrowser 和白名单
    • file.html中没有重新加载所有js文件,所以不需要子浏览器
    猜你喜欢
    • 1970-01-01
    • 2016-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-08
    • 1970-01-01
    相关资源
    最近更新 更多