拖拽框

<!DOCTYPE  html >
<html  lang= "en" >
<head>
    <meta  charset= "UTF-8" >
    <title> 综合案例 </title>
    <style>
        #container{ positionabsolute ; display: none ; width: 400 px ; height: 300 px ; border: 1 px solid  #ccc ; border-radius: 10 px ;}
        #sp{ padding-right: 10 px ; color: red ; border-radius: 10 px  10 px  0 0 ; width: 390 px ; height: 50 px ; background: #1883ba ; font-size: 30 px ; line-height: 50 px ; text-align: right ;}
        #box{ width: 400 px ; height: 450 px ;}
        #count{ width: 300 px ; height: 40 px ; line-height: 40 px ; font-size: 28 px ; margin: 20 px auto ;}
        #pwd{ width: 300 px ; height: 40 px ; line-height: 40 px ; font-size: 28 px ;}
    </style>
</head>
<body>
<button  id= "login" > 点击开始注册 </button>
<div  id= "container" >
    <div  id= "sp" ><span  id= "ssp" >[ X ] </span></div>
    <div  id= "box" >
        账号: <input  type= "text"  id= "count" ><br/>
        密码: <input  type= "password"  id= "pwd" >
    </div>
</div>
<script>
    var _log =  document. getElementById( "login") ;
    var cont =  document. getElementById( "container") ;

    _log. onclick function(){
        cont. style. display "block" ;
        var _c =  document. cookie ;
        //console.log(_c);
        var _a = _c. split( ";") ;
        console. log(_a) ;
        var _x = _a[ 0]. trim(). substring( "postx=". length) ;
        var _y = _a[ 1]. trim(). substring( "posty=". length) ;
        console. log(_x) ;
        console. log(_y) ;
        var jsonx =  JSON. parse(_x) ;
        var jsony =  JSON. parse(_y) ;
        console. log(jsonx. x) ;
        console. log(jsony) ;
        cont. style. left = jsonx. "px" ;
        cont. style. top = jsony. "px" ;

        //console.log(_x);
    }
    ssp. onclick function(){
        cont. style. display "none" ;
    }
    sp. onmousedown function(e){
        e = e ||  window. event ;
        var _ox = e. offsetX ;
        var _oy = e. offsetY ;
        document. onmousemove function(e){
            e = e ||  window. event ;
            var _cx = e. clientX ;
            var _cy = e. clientY ;
            var _left = _cx - _ox ;
            var _top = _cy - _oy ;
            if(_left <  0){_left =  0}
            if(_top <  0){_top =  0}
            if(_left + cont. offsetWidthdocument. documentElement. clientWidth ){
                _left =  document. documentElement. clientWidth - cont. offsetWidth ;
            }
            cont. style. left = _left +  "px" ;
            cont. style. top = _top +  "px" ;

            px '{"x":'+_left+ "}" ;
            py '{"y":'+_top+ "}" ;
            var date =  new Date() ;
            date. setDate(date. getDate() +  3) ;
            document. cookie "postx="px + ";expires=" +date.toGMTString() ;
            document. cookie "posty="py + ";expires=" +date.toGMTString() ;
        }
    }
    sp. onmouseup function () {
        document. onmousemove null ;
    }

</script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值