• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 在 Cordova 中使用 Button 进行登录验证后重定向

[复制链接]
菜鸟教程小白 发表于 2022-12-12 14:52:41 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我是 Cordova 语言的初学者。我正在尝试在 javascript 中单击按钮时重定向我的 html 页面。在 validateform 方法中,我想重定向到我的主页。我已经尝试了所有可能的东西,例如 window.location, document.location 。但我没有得到重定向的确切答案。

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript">
        window.onload = function()
        {
            document.addEventListener("deviceready", init, false);
        }

    function init()
    {
        var myButton = document.getElementById("BtnClick");
        myButton.addEventListener("click", validateform, false);
    }

    function validateform()
    {
        var myButton = document.getElementById("BtnClick");
        var user = document.getElementById("username").value;
        var paswd = document.getElementById("password").value;
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

        if (user == "") {
            alert("Name must be filled out");
            return false;
        } else if (reg.test(user) == false) {
            alert("Invalid Email Address");
            return false;
        } else  if (paswd == "") {
            alert("assword must be filled out");
            return false;
        } else {
            alert("TRY!");
            document.location = "home.html";
            return false;
        }
    }
        </script>

    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
        <meta name="format-detection" content="telephone=no">
            <meta name="msapplication-tap-highlight" content="no">
                <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
                    <link rel="stylesheet" type="text/css" href="css/index.css">
                        </head>

<body>
    <form id="loginForm" class = "centered" >
        <div class="middle">
            <img src = "img/newlogo.png" width="150" height="150"/>
        </div>

        <div data-role="fieldcontain">
            <input type="email" name="username" id="username" value="[email protected]" placeholder="Username" class="middle textfield"/>
        </div>

        <div data-role="fieldcontain" >
            <input type="password" name="password" id="password" value="789456" placeholder="assword" class="middle textfield" maxlength="10"/>
        </div>

        <div class = "middle">
            <button id = "BtnClick" class = "button" >Submit</button>
        </div>
    </form>
</body>
</html>



Best Answer-推荐答案


感谢大家的帮助!我找到了解决方案:

index.html

<div class = "loginButton">
      <a id = "BtnClick">Submit</a>
</div>

validateform方法中:

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

关于ios - 在 Cordova 中使用 Button 进行登录验证后重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52420959/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap