从phonegap中的javascript重定向到本地html页面

时间:2011-10-04 06:05:41

标签: javascript html cordova

我正在开发phonegap应用程序。 我正在尝试登录,点击Login.html中的提交按钮,我应该重定向到本地的html文件。

的login.html

<tr>
    <td>&nbsp;</td>
    <td>
        <input type="submit" class="submitbtn" name="submit"
            id="submit" value="Login" onclick="loginCheck()">
    </td>
</tr>

loginValidation.js

if (validCustomer == true) {

    alert("valid customer........");
    document.location.href("file:///android_asset/www/Category.html"); 

document.location.hrefwindow.location / window.open不起作用。有人可以帮忙解决这个问题吗? 如果我使用window.open并在模拟器中运行应用程序,它可以正常工作但不在设备中。

4 个答案:

答案 0 :(得分:5)

你可以试试这个

window.open("mainpage.html",'_self');

这将打开当前窗口中的页面,以便当前窗口页面数据得到刷新,新页面数据将在同一个窗口页面dom中呈现。

答案 1 :(得分:0)

尝试使用相对路径,这应该有效:

window.location="Category.html";

答案 2 :(得分:-1)

试试这个

window.location.replace = "Category.html";

答案 3 :(得分:-1)

window.location.href = 'Category.html';
相关问题