ajax 사용자 이름 이 점용 되 었 는 지 확인 합 니 다.


//
function GetO(){
var ajax=false;
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
ajax = false;
}
}
if (!ajax && typeof XMLHttpRequest!='undefined') {
ajax = new XMLHttpRequest();
}
return ajax;
}
function getResult(serverPage) {
var ajax = GetO();
var sep = (-1 < serverPage.indexOf("?")) ? "&" : "?"
var newurl = serverPage + sep + "__=" + encodeURIComponent((new Date()).toString());

ajax.open("GET", newurl, true);
ajax.onreadystatechange = function() {
if (ajax.readyState == 4 && ajax.status == 200) {
if(ajax.responseText==1){
ShowResult(1," ")
AjaxResult=true;
}else{
ShowResult(0," ")
AjaxResult=false;
}
}
}
ajax.send(null);

}
function chkUsername(){
var sflag;// ;
var sErr;// ;
sflag=true;

var re=/^\w{2,20}$/;
if(!re.test(document.Form1.UserName.value)){
sflag=false;
sErr=" 、 ";
}

if (document.Form1.UserName.value.length>20||document.Form1.UserName.value.length<2){
sflag=false;
sErr=" 2~20 ";
}
if (document.Form1.UserName.value=="" ){
sErr=" ";
sflag=false;
}
//ajax
if (!sflag) {
ShowResult(0,sErr)
}else{
getResult("../MemberCheck.aspx?t=1&Name=" + document.Form1.UserName.value);
}

//document.getElementById("spname").innerHTML=ss;
}
function ShowResult(tag,str){
var obj = document.getElementById("spname");
if(tag==0){
obj.style.border="1px solid red";
obj.style.color="red";

}else{
obj.style.border="1px solid green";
obj.style.color="green";
}
obj.innerHTML=str;
obj.style.padding="1px";
}
// ajax
function getQuestionData(sPage){
var ajax = GetO();
var sep = (-1 < sPage.indexOf("?")) ? "&" : "?"
var newurl = sPage + sep + "__=" + encodeURIComponent((new Date()).toString());

ajax.open("GET", newurl, true);
ajax.onreadystatechange = function() {
if (ajax.readyState == 4 && ajax.status == 200) {
if(ajax.responseText==""){
document.getElementById("getstate").innerHTML=" !"
}
else{
document.g.Question.value=ajax.responseText;
document.g.Question.readOnly=true;
document.getElementById("getpwdstep1").style.display="none";
document.getElementById("getpwdstep2").style.display="block";
document.getElementById("getstate").innerHTML="";

}
}
}
ajax.send(null);
}
function getUserQ(){
// span
document.getElementById("getstate").style.padding="1px 4px";
if (document.g.UserName.value==""){
document.getElementById("getstate").innerHTML=" !"
}else{
document.getElementById("getstate").style.background="red";
document.getElementById("getstate").style.color="white";
document.getElementById("getstate").innerHTML=" ...";
// ajax
getQuestionData("../MemberCheck.aspx?t=2&gName=" + document.g.UserName.value);
}
}

function login(n,p,t)
{
if(t==false){
document.getElementById("pLogin").style.display="none";
document.getElementById("LoginInfo").innerHTML=" , ...";
}
var request;
if(undefined == request){
request = new Request();
}

if(undefined == request._get){
// Ajax ;
if(t==false){
document.getElementById("pLogin").style.display="";
document.getElementById("LoginInfo").innerHTML=" ";
}
}
else{
userName=n;
toPrev=t;
request.GetNoCache(loginPath + "LoginCheck.aspx" + "?n=" + n + "&p=" + p,loginCheck);
}
}
function loginCheck(result)
{
if (result.readyState!=ReadyState.Complete)
return;
// ;
if (result.status==HttpStatus.OK && result.responseText != "")
{
// ;
//alert(result.responseText);
if (result.responseText=='1')
{
if(toPrev ==false){
document.getElementById("LoginInfo").innerHTML='<ul><li> ' + userName + '</li><li><a href="' + loginPath + 'member/"> </a></li><li><a href="' + loginPath + 'Logout.aspx"> </a></li></ul>';
}
else{
if(UrlPrev != ''){
document.location.href=UrlPrev;
}
else{
document.location.href=loginPath;
}
}
return;
}
else
{
if(document.location.href !="http://" + document.location.hostname + loginPath + "Member/Login.aspx")
document.location.href=loginPath + "Member/Login.aspx";
}
}
else
{
// ;
document.location.href=loginPath + "Member/Login.aspx";
return;
}
}
function checkKey(caputureKey,n,p,t){
var key = window.event.keyCode;
if(key == caputureKey){
login(n,p,t);
}
}
function setLoginInfo(bLogin){
if(bLogin){
document.getElementById("LoginInfo").innerHTML='<ul><li> ' + userName + '</li><li><a href="' + loginPath + 'member/"> </a></li><li><a href="' + loginPath + 'Logout.aspx"> </a></li></ul>';
}
else{
}
}
function gotoUrl(s){
window.location.href=loginPath + 'Member/RegUser.html';
}

좋은 웹페이지 즐겨찾기