以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助] 安卓企业微信里面 网页清楚cookie之后 返回 登陆页面 按手机的返回键 可以回到刚才的页面 但是操作一下 就回登陆界面  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=136492)

--  作者:TINOOOOOOOO
--  发布时间:2019/6/14 13:51:00
--  [求助] 安卓企业微信里面 网页清楚cookie之后 返回 登陆页面 按手机的返回键 可以回到刚才的页面 但是操作一下 就回登陆界面
想问的是  有什么办法可以  防止返回键 回到刚才的页面  直接刷新成  新的登陆页面


Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI
Dim Verified As Boolean \'用于标记用户是否通过了身份验证
Dim UserName As String = e.Cookies("username") \'从cookie中获取用户名
Dim Password As String = e.Cookies("password") \'从cookie中获取用户密码
If e.Path = "logon.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then
        UserName = e.PostValues("username")
        Password = e.PostValues("password")
    End If
End If
If UserName = "花花" AndAlso Password = "huahua" Then  \'实际使用的时候,请改为从数据库读取用户名和密码进行比较
    Verified  = True
ElseIf Username = "草草" AndAlso Password="caocao" Then
    Verified  = True
End If
If Verified AndAlso e.Path = "logon.htm"  Then \'如果用户访问的是登录页,且身份验证成功
    wb.AppendCookie("username",UserName) \'将用户名和密码写入cookie
    wb.AppendCookie("password",Password)
    wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'直接跳转到首页
    e.WriteString(wb.Build) \'生成网页  
ElseIf Verified = False AndAlso e.Path <> "logon.htm" Then \'如果用户身份验证失败,且访问的不是登录页面
    wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'那么直接跳转到登录页面
    e.WriteString(wb.Build) \'生成网页
End If

Select Case e.Path
    Case "exit.htm"
        wb.AddForm("","form1","exit.htm")
        With wb.AddButtonGroup("form1","btg1",True)  \'垂直排列
            .Add("btn6", "退出","logon.htm")

             wb.DeleteCookie("username") \'清除cookie中原来的用户名和密码
             wb.DeleteCookie("password")
             wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") 

End With
End Select
e.WriteString(wb.Build)

这个是 退出页面的代码  

--  作者:有点甜
--  发布时间:2019/6/14 15:22:00
--  

禁用返回键试试,代码写到weui.me.js里面

 

    pushHistory();
    function pushHistory() {
        window.addEventListener("popstate", function(e) {
            //alert("后退");
            self.location.reload();
        }, false);
        var state = {
            title : "",
            url : "#"
        };
        window.history.replaceState(state, "", "#");
    };


--  作者:blackzhu
--  发布时间:2019/6/15 11:00:00
--  
我用的第三方框架也是的,后来没办法做了返回按钮