海天的页首,暂无

登录成功返回登录前页面js代码

/*------ setCookie(name,value) -----------*/

function setCookie(name,value)

{

var Days = 30; //此 cookie 将被保存 30 天

var exp = new Date();

exp.setTime(exp.getTime() + Days*24*60*60*1000);

document.cookie = name + "="+ escape (value) + ";expires=" + exp + ";path=/";

}

/*-------- getCookie(name) ----------*/

function getCookie(name)

{

var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));

if(arr !=null) return unescape(arr[2]); return null;

}

 

$(function(){

if($("#header")[0]){

setCookie("currentUrl", window.location.href);

}

})

调用

 var currentUrl = getCookie('currentUrl');

    setCookie("currentUrl", "");

$.ajax({

   type: "post",

   url: "/Ajax/User.ashx",

   data: { "method": "Login", "username": $(".phoneNum").val(), "password": password, "Check_Pwd": $('#check').is(':checked') },

   success: function (text) {

       if (text == "error") {

                $(".pwd").focus().tips({

                    bg:'#1193f6',

                    msg: '用户名或密码错误~'

                });

       }

       else if (text == "error1") {

                $(".phoneNum").focus().tips({

                    bg:'#1193f6',

                    msg: '该用户已被禁用~'

                });

            }

       else if(text == "success") {

           if (currentUrl != "" && currentUrl != null) {

                    window.location.href = currentUrl;

                } else {

                    window.location = '/index';

                }  

       }

   }

});

posted @ 2016-11-25 15:42  海天网  阅读(4087)  评论(0编辑  收藏  举报
海天的页脚,暂无