累似qzone登录代码

来源:互联网 发布:java 对数组随机排序 编辑:程序博客网 时间:2024/05/17 23:57

function checkchar(it,mes)
{

var x="'><  "
for(var i=0;i<it.length;i++)
{

 bl=it.substring(i,i+1)
 
  if (x.indexOf(bl)>=0)
 {
 alert(mes)
 return false
 }
 
}
return true
}


function check1a()
{
if(document.form1.name1.value=="")
{
alert("请输入用户名")
return false
}
if(document.form1.pass1.value=="")
{
alert("请输入密码")
return false
}
 if(checkchar(document.form1.name1.value,"用户名中含有非法字符")==false)
 {
 return false
 }
 
 if(checkchar(document.form1.pass1.value,"密码中含有非法字符")==false)
 {
 return false
 }
 login1()
}

var move_obj_x0=0,move_obj_y0=0,move_obj_x1=0,move_obj_y1=0;//(x0,y0)为开始拖动时鼠标的位置(x1,y1)为开始拖动时对象的位置
var obj_moveable=false;

//开始拖动;
function startDrag(obj,id)
{
    if(event.button==1)
    {
        //obj.setCapture();
        win=document.getElementById(id)
        move_obj_x0 = event.clientX;
        move_obj_y0 = event.clientY;
        move_obj_x1 = parseInt(win.style.left);
        move_obj_y1 = parseInt(win.style.top);
        obj_moveable = true;
    }
}
//拖动;
function drag(id)
{
    if(obj_moveable)
    {
        win=document.getElementById(id)
        win.style.left = (move_obj_x1 + event.clientX - move_obj_x0>0)?move_obj_x1 + event.clientX - move_obj_x0:0;
        win.style.top = (move_obj_y1 + event.clientY - move_obj_y0>0)?move_obj_y1 + event.clientY - move_obj_y0:0;
    }
}
//停止拖动;
function stopDrag(obj,id)
{
    if(obj_moveable)
    {
       // obj.releaseCapture();
        obj_moveable = false;
    }
}

function displaylogin()
{
document.getElementById("logindiv").style.display=""
document.getElementById("logindiv").focus()
}
function error()
{
//alert("登录超时");
//显示层进行登录
displaylogin()
}

function closediv()
{

document.getElementById("logindiv").style.display="none"
}

function getXMLRequester( ){
    var xmlhttp_request= false;
    try{
        if( window.ActiveXObject ){
            for( var i = 5; i; i-- ){
                try{
                    if( i == 2 ){
xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" );   
                    }else{
xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" ); 
xmlhttp_request.setRequestHeader("Content-Type","text/xml");
xmlhttp_request.setRequestHeader("Content-Type","gb2312");
                 }
break;}
                catch(e){                       
                    xmlhttp_request = false;
                }
            }
        }else if( window.XMLHttpRequest ){
            xmlhttp_request = new XMLHttpRequest();
            if (xmlhttp_request.overrideMimeType) {
                xmlhttp_request.overrideMimeType('text/xml');
            }
        }
    }catch(e){
        xmlhttp_request = false;
    }
    return xmlhttp_request ;
}

    function login1(){

        url="/login.asp?orders=2"
        para="name1="+escape(document.form1.name1.value)+"&pass1="+escape(document.form1.pass1.value)+"&dltype=2"
        xmlhttp_request=new getXMLRequester();//调用创建XMLHttpRequest的函数
        xmlhttp_request.onreadystatechange = function()
        {
                if (xmlhttp_request.readyState == 4) {// 收到完整的服务器响应
            if (xmlhttp_request.status == 200) {//HTTP服务器响应的值OK

           xxx=xmlhttp_request.responseText;
           //alert(xxx)
           if(xxx=="1")
           {
           closediv()
           //location.reload()
           document.all("info").innerHTML="登录成功!";
           }
           else
           {
           document.all("info").innerHTML="登录失败!";
           }

            } else {
                //alert(xmlhttp_request.status);
            }
        }
       
       
        };
        //调用doContents函数
       // setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
      
       xmlhttp_request.open('POST',url,true);
       xmlhttp_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
       xmlhttp_request.send(para);

    }


    function checkdl(ask){

        url="zhidao_dl_login.asp"
        xmlhttp_request=new getXMLRequester();//调用创建XMLHttpRequest的函数
        xmlhttp_request.onreadystatechange = function()
        {
            if (xmlhttp_request.readyState == 4) {// 收到完整的服务器响应
            if (xmlhttp_request.status == 200) {//HTTP服务器响应的值OK

               rl=xmlhttp_request.responseText;
               if(rl=="1")
               {
               ask.submit()
               return true;
               }
               else
               {
               error()
               return false;
               }

           
            } else {
                //alert(xmlhttp_request.status);
            }
        }
       
       
        };
        //调用doContents函数
       // setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
      
       xmlhttp_request.open('GET',url,true);
       //xmlhttp_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
       xmlhttp_request.send(null);

    }

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<style>
body{font-size:12px}
table{font-size:12px}
.shadow1 {font-size:12px;cursor:hand;position:absolute;left:50%;top:50%;width:180px; height:210px;margin-top:-105px;margin-left:-90px; filter: dropshadow(color="#aaaaaa", offx=5, offy=5, positive=1) Alpha(Opacity=90);
}
</style>

<script language="javascript" src="zhidao_dl_js.js"></script>
</head>
<body>
<div id="logindiv"  class=shadow1  style="display:none;position:absolute;left:50%;top:50%;width:180px; height:210px;margin-top:-105px;margin-left:-90px">
 <table width=169 height=199 style="background-color:white;border: 1px black solid">
  <tr><td valign="top">
 <table border="0" cellpadding="0" cellspacing="0" width="100%" height="150" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF">
  <form name="form1"><tr>
   <td colspan="2" height="30">
   <table border="0" cellpadding="0" cellspacing="0" width="100%" height="26" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF">
    <tr>
     <td><b>&nbsp;<font color="#BD0000">养殖网快速登录</font></b></td>
     <td>[<a href="#" onclick="closediv()" class="a2">关闭</a>]</td>
    </tr>
   </table></td>
  </tr>
  <tr>
   <td colspan="2" height="25">&nbsp;<b>请你登录</b></td>
  </tr>
  <tr>
   <td width="40%" height="25">&nbsp;用户名</td>
   <td width="57%" height="25"><input type="text" name="name1" size="8"></td>
  </tr>
  <tr>
   <td width="40%" height="25">&nbsp;密码</td>
   <td width="57%" height="25"><input type="password" name="pass1" size="8"></td>
  </tr>
  <tr>
   <td width="40%" height="25"> </td>
   <td width="57%" height="25"><input type="button" value="登录" name="B1" onclick="check1a()"></td>
  </tr>
  <tr>
   <td width="97%" colspan="2" align="center" height="25"><div id="info"></div></td>
  </tr>
  <tr>
   <td width="97%" colspan="2" align="center" height="25"> </td>
  </tr>
 </table>
 </form>
 </td></tr>
 </table>
</div>
</body> 

调用  /*判断是否登录*/
        checkdl(document.formhf)

原创粉丝点击