muxrwc

厕所专栏

王辰ID:muxrwc
17070次访问,排名6811好友76人,关注者99
codeing,玩,睡,画画(很小的时候)
muxrwc的文章
原创 51 篇
翻译 1 篇
转载 12 篇
评论 25 篇
muxrwc的公告
昂。。。偶文采不好。。。。写文章好累,偶会慢慢更新滴。。。:D
最近评论
dh20156:确实太BT了。IE不严谨吧
s_liangchao1s:学习
cloudgamer:不错
dead_of_winter:对了 你给我看那个寻路 根本就是错的嘛 找不到最优路径的......
muxrwc:@.@数学不好的飘走...
文章分类
收藏
    相册
    WC
    喜欢的图片
    DHTML精英俱乐部-伟大的前辈们。。。
    伟大的aoao前辈。。。
    伟大的EMU前辈。。。
    伟大的FS前辈。。。
    伟大的JK前辈。。。
    伟大的winter同学...(RSS)
    伟大的兔老师。。。。
    伟大的月影大姐姐。。。
    伟大的水水前辈。。。
    伟大的石头君。。。
    伟大的顺子前辈。。。
    伟大的飘飘前辈。。。
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 鼠标选择框特效。。。。收藏

    新一篇: 翻页特效。。。 | 旧一篇: JS控制CSS

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>鼠标特效</title>
    <script type="text/javascript">
    (function (bool) {
    //兼容FF一些方法
        var html;
       
        window.IE = /MSIE/.test(window.navigator.userAgent);
       
        if (bool) {
       
            html = window.HTMLElement.prototype;
           
            window.__defineGetter__("event", function () {
            //兼容Event对象
                var o = arguments.callee;   
               
                do {
                    if (o.arguments[0] instanceof Event) return o.arguments[0];           
                } while (o = o.caller);
               
                return null;
            });
        }
       
    })(/Firefox/.test(window.navigator.userAgent));


    var Class = {
    //创建类
        create : function () {
            return function () {
                this.initialize.apply(this, arguments);
            };
        }
    };

    var $A = function (a) {
    //转换数组
        return a ? Array.apply(null, a) : new Array;
    };

    Object.extend = function (a, b) {
    //追加方法
        for (var i in b) a[i] = b[i];
        return a;
    };

    Object.extend(Object, {

        addEvent : function (a, b, c, d) {
        //添加函数
            var $ni, $nf;
            if (b.constructor != Array) { $ni = $nf = b; }
            else { $ni = b[0], $nf = b[1]; }
           
            if (a.attachEvent) a.attachEvent($ni, c);
            else a.addEventListener($nf.replace(/^on/, ""), c, d || false);
            return c;
        },
       
        delEvent : function (a, b, c, d) {
        //删除函数
            var $ni, $nf;
            if (b.constructor != Array) { $ni = $nf = b; }
            else { $ni = b[0], $nf = b[1]; }
           
            if (a.detachEvent) a.detachEvent($ni, c);
            else a.removeEventListener($nf.replace(/^on/, ""), c, d || false);
            return c;
        }
       
    });

    Function.prototype.bind = function () {
    //绑定事件
        var wc = this, a = $A(arguments), o = a.shift();
        return function () {
            wc.apply(o, a.concat($A(arguments)));
        };
    };

    var CMouse = Class.create();

    CMouse.prototype = {
       
        initialize : function (obj) {
        //初始化参数
            var wc = this;
            wc.div = wc.init_div();
            wc.click = null; //鼠标按下后记录其坐标
            wc.sFunc = Object.addEvent(document, "onmousedown", wc.sMove.bind(wc));
            wc.iFunc = wc.eFunc = null;
        },
       
        init_div : function () {
        //创建DIV,修改样式,并返回
            var div = document.createElement("div");
           
            with (div.style) {
                position = "absolute";
                zIndex = 100;
                overflow = "hidden";
                display = "none";
                width = height = top = left = "0px";
                border = "#CCCCCC 1px solid";
                backgroundColor = "#F4F4F4";
                filter = "alpha(opcaity=50)";
                opacity = "0.5";
            }
           
            div.innerHTML = "&nbsp;";
            return document.body.appendChild(div);
        },
       
        reMouse : function () {
        //获取鼠标位置
            var e = window.event;
            return {
                x : document.documentElement.scrollLeft + e.clientX,
                y : document.documentElement.scrollTop + e.clientY
            };
        },
       
        eDiv : function (pos) {
        //处理DIV
            var wc = this, div = wc.div;
           
            with(div.style) {
                left = pos.left + "px";
                top = pos.top + "px";
                width = pos.width + "px";
                height = pos.height + "px";
            }
        },
       
        sMove : function () {
        //鼠标按下后
            var wc = this;
           
            wc.click = wc.reMouse();
           
            if (wc.iFunc) return true;
           
            with (wc.div.style) {
                display = "block";
                width = height = "0px";
            }
           
            wc.iFunc = Object.addEvent(document, "onmousemove", wc.iMove.bind(wc));
            wc.eFunc = Object.addEvent(document, "onmouseup", wc.eMove.bind(wc));
        },
       
        iMove : function () {
        //鼠标移动时
            var wc = this, oms = wc.click, mos = wc.reMouse()
           
            wc.eDiv({
                left : Math.min(mos.x, oms.x), top : Math.min(mos.y, oms.y),
                width : Math.abs(mos.x - oms.x), height : Math.abs(mos.y - oms.y)
            });
           
            if (window.IE) wc.div.setCapture(); //为了拽出浏览器
           
            try {
                if (document.selection) document.selection.empty();
                else window.getSelection().removeAllRanges();
            } catch (exp) {}
        },
       
        eMove : function () {
        //鼠标松开后
            var wc = this;

            if (window.IE) wc.div.releaseCapture(); //为了拽出浏览器
           
            wc.div.style.display = "none";
           
            Object.delEvent(document, "onmousemove", wc.iFunc);
            Object.delEvent(document, "onmouseup", wc.eFunc);   
            wc.click = wc.iFunc = wc.eFunc = null;
           
        }
       
    };

    var win_load = Object.addEvent(window, "onload", function () {
        var mouse = new CMouse, div = document.createElement("div");
        div.innerHTML = new Array(101).join("<br \/>");
        document.body.appendChild(div);
    });
    </script>
    </head>
    <body></body>
    </html> 

    发表于 @ 2007年09月20日 13:32:00|评论(loading...)|编辑

    新一篇: 翻页特效。。。 | 旧一篇: JS控制CSS

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © muxrwc