登錄成功返回登錄前頁面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';

                }  

       }

   }

});


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM