关于作者

漂亮的层模拟窗体MoveWindow(未封装),基本功能兼容FF^_^

上一篇 / 下一篇  2007-04-27 01:23:25 / 个人分类:JScript编程

查看( 1584 ) / 评论( 11 )

CODE:

<html>
<head>
<title>MoveWindow_Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<style type="text/css">
body {
        margin:0px;
}
a:link,a:visited {
        color:#450600;
        text-decoration:none;
        cursor:default;
}
a:hover {
        color:#ff0000;
        text-decoration:none;
        cursor:default;
}
</style>
</head>
<body>
<div id="_alert" style="
        position:absolute;
        filter:progid:DXImageTransform.Microsoft.DropShadow(color=#c0c0c0,offX=4,offY=4,positives=true);
        z-index:100;
        top:130px;
        left:220px;
        width:300px;
        font-size:12px;
        border:1px solid #cccccc;">
        <div style="
                filter:Alpha(opacity=50);
                width:82%;
                height:26px;
                float:left;
                cursor:move;
                line-height:26px;
                background:#f0f0f0;
                text-indent:3px;"
                onmousedown="run('_alert',event);">
                <font style="font-size:16px;font-family:wingdings">î</font> <b>无忧脚本论坛</b>
        </div>
        <div style="
                filter:Alpha(opacity=50);
                width:18%;
                height:26px;
                float:left;
                font-size:14px;
                font-family:webdings;
                cursor:default;
                line-height:26px;
                background:#fffeee;
                text-align:right;">
                <a href="#" onclick="mix('_alert','_alert_c');">&#48;</a><a href="#" onclick="max('_alert','_alert_c',this);">&#49;</a><a href="#" onclick="cos('_alert');">r</a> 
        </div>
        <div id="_alert_c" style="
                filter:Alpha(opacity=50);
                width:100%;
                height:150px;
                padding:10px;
                background:#fffff3;
                border-top:1px solid #cccccc;">
                <br /><br />无忧脚本是个什么组织?<br />
                是个学习、讨论、研究JavaScript的地方!
        </div>
</div>
<script language="JavaScript">
document.body.oncontextmenu = function(){
        window.event.returnValue = false;
}
document.body.onselectstart = function(){
        return false;
}
var _ty,_tx,_cy,_cx,_sw_so,_sh_sb;
function run(obj,event){
        var _so = document.getElementById(obj);
        var _sc = true;
        var _sy = event.clientY;
        var _sx = event.clientX;
        _so.style.background = "#cccccc";
        if(_so.style.width == document.body.clientWidth - 4 + "px"){
                _sc = false;
        }
        _so.onmouseup = function(){
                _sc = false;
                _so.style.background = "";
        }
        _so.onmousemove = function(){
                if(_sc == true){
                        var _xy = event.clientY - _sy;
                        var _xx = event.clientX - _sx;
                        this.style.top = parseInt(this.style.top) + _xy + "px";
                        this.style.left = parseInt(this.style.left) + _xx + "px";
                        _sy = event.clientY;
                        _sx = event.clientX;
                }
        }
}
function mix(obj1,obj2){
        var _so = document.getElementById(obj1);
        var _sb = document.getElementById(obj2);
        if(_sb.style.display == ''){
                _ty = _so.style.top;
                _tx = _so.style.left;
                _sb.style.display = 'none';
                _so.style.left = "0px";
                _so.style.top = document.body.clientHeight - 32 + "px";
        }
        else {
                _sb.style.display = '';
                _so.style.left = _tx;
                _so.style.top = _ty;
        }
}
function max(obj1,obj2,obj3){
        var _so = document.getElementById(obj1);
        var _sb = document.getElementById(obj2);
        var _sw = document.body.clientWidth - 4 + "px";
        var _sh = document.body.clientHeight - 32 + "px";
        if(_so.style.width != _sw){
                _cy = _so.style.top;
                _cx = _so.style.left;
                _sw_so = _so.style.width;
                _sh_sb = _sb.style.height;
                _so.style.top = "0px";
                _so.style.left = "0px";
                _so.style.width = _sw;
                _sb.style.height = _sh;
                obj3.innerHTML = "&#50;";
        }
        else{
                _so.style.width = _sw_so;
                _sb.style.height = _sh_sb;
                _so.style.top = _cy;
                _so.style.left = _cx;
                obj3.innerHTML = "&#49;";
        }
}
function cos(obj){
        document.getElementById(obj).style.display = "none";
}
</script>
</body>
</html>
[ 本帖最后由 biyuan 于 2007-4-27 01:44 编辑 ]

TAG:

gene的个人空间 gene 发布于2007-04-27 01:31:24
又一个窗体
不过蛮漂亮的

1 . 很多情况下 onmouseup 无法捕捉到 ,比如在网页外放开.    造成窗口粘在鼠标上
2 . 有滚动条时拖不动...
3 . 最大化时应不允许拖动
gene的个人空间 gene 发布于2007-04-27 01:41:32
我觉得最大化的时候应该用百分比

这样改变网页大小的时候  窗体也是最大化的状态
biyuan老矣 biyuan 发布于2007-04-27 01:45:45

QUOTE:

原帖由 gene 于 2007-4-27 01:31 发表
又一个窗体
不过蛮漂亮的

1 . 很多情况下 onmouseup 无法捕捉到 ,比如在网页外放开.    造成窗口粘在鼠标上
2 . 有滚动条时拖不动...
3 . 最大化时应不允许拖动
第三个问题已经修正。
另外两个明天再搞。。
本来打算写个简单的拖动,没想到越写代码越多,考虑的因素越多
刚开始还照顾一下FF,到后来就干脆懒得理FF了
HITS发布于2007-04-27 08:35:58
沒有屏蔽SELECT
tingwei的个人空间 tingwei 发布于2007-04-27 08:40:29
我先收藏了
岁月有痕 dron 发布于2007-04-27 08:45:09
老碧也出窗体了, 支持一下
Mapleleaf123发布于2007-04-27 09:15:39
收藏
大大IT发布于2007-04-30 11:07:18
太强了.收藏.
sycs发布于2007-04-30 11:19:45
ff 下有问题,不能拖动。一点就跑左上角去了。
赖小子发布于2007-04-30 18:39:37
很好看啊

strand发布于2007-05-01 23:44:30

我来说两句

(可选)