首页 新闻 搜索 专区 学院

我找我婶婶。囧........

0
悬赏园豆:50 [待解决问题]

你运行一下这段代码

/*
wanMessageBox弹出框
msg: 将要显示的信息,如果需要换行以 々 符号隔开
rowHeight: 每行显示的高度,
width:消息框的宽度
*/
function wanMessageBox(msg, rowHeight, width) {
    var pop = window.createPopup();

    var _msg = "";
    var arr = msg.split('々');
    var rowCount = arr.length + 1;
    for (var i = 0; i < arr.length; i++) {
        if (_msg != "") _msg += "<br /> ";
        _msg += arr[i];
    }

    var w = width;
    var h = rowCount * rowHeight + 30;
    /* */
    //居中显示
    var l = (document.body.clientWidth - w) / 2;
    var t = (document.body.clientHeight - h) / 2;

    /*
    //显示在右下方
   
    var l = document.body.scrollWidth - w - 1;
    var t = document.body.clientHeight - h - 1;
    */
    var container = document.createElement("div");

    var items = document.createElement("div");
    items.style.cssText = "z-index:50001; background:#fff; top:" + t + "px; left:" + l + "px; width:" + w + "px; height:" + h + "px; border:4px double #99CCFF;font-size:14px; font-family:宋体;position:absolute;";
    items.onmousedown = mousedown;

    var title = document.createElement("div");
    title.style.cssText = "width:100%; height:26px; cursor:move; line-height:26px; padding-left:5px; background:#fff; border-bottom:1px solid #99CCFF;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#99CCFF, EndColorStr=#EEF7FF);";

    var title_left = document.createElement("div");
    title_left.style.cssText = "float:left;font-weight:bold; color: #113DAE;";
    title_left.innerText = "系统消息";

    var title_right = document.createElement("div");
    title_right.style.cssText = "float:right; font-family:Webdings; font-size:16px; color: white; text-align:center; width:40px; cursor: pointer;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#F0172D, EndColorStr=#ECF5FF);";
    title_right.onclick = _hide;
    title_right.innerText = "r";

    var message = document.createElement("div");
    message.style.cssText = "padding:10px;margin:0; line-height:130%; color:black;";
    message.innerHTML = " " + _msg;

    title.appendChild(title_left);
    title.appendChild(title_right);
    items.appendChild(title);
    items.appendChild(message);
    container.appendChild(items);

    var bgDiv = document.createElement("div");
    bgDiv.style.cssText = " Z-INDEX: 50000; FILTER: alpha(opacity=50); LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 100%; BACKGROUND-COLOR: #BCBCBC; moz-opacity: 0.5; opacity: 0.5";
    bgDiv.onmouseup = function() { return false; }
    bgDiv.onmousemove = function() { return false; }
    bgDiv.onmousedown = function() { return false; }
    bgDiv.onmousedown = function() { return false; }
    bgDiv.ondblclick = function() { return false; }
    bgDiv.onclick = function() { return false; }
    bgDiv.oncontextmenu = function() { return false; }
    bgDiv.onselectstart = function() { return false; }

    document.body.appendChild(container);
    document.body.appendChild(bgDiv);

    _setSelectDisplay("none");

    var x, y, dragObj;
    function mousedown() {
        var obj = event.srcElement.parentNode;
        dragObj = obj;
        dragObj.onmousemove = mousemove;
        dragObj.onmouseup = mouseup;
        dragObj.setCapture();

        oEvent = window.event ? window.event : event;
        x = oEvent.clientX;
        y = oEvent.clientY;
    };
    function mousemove() {
        oEvent = window.event ? window.event : event;
        var _top = oEvent.clientY - y + parseInt(dragObj.style.top);
        var _left = oEvent.clientX - x + parseInt(dragObj.style.left);
        if (_left < 1) _left = 1;
        if (_top < 1) _top = 1;
        var sw = document.body.scrollWidth - dragObj.offsetWidth - 1;
        var sh = document.body.clientHeight - dragObj.offsetHeight - 1;
        if (_left > sw) _left = sw;
        if (_top > sh) _top = sh;

        try {
            dragObj.style.top = _top + "px";
            dragObj.style.left = _left + "px";
        }
        catch (e) { }
        x = oEvent.clientX;
        y = oEvent.clientY
    };
    function mouseup() {
        dragObj.onmousemove = null;
        dragObj.onmouseup = null;
        dragObj.releaseCapture();
        dragObj = null;
    };

    function _hide() {
        container.style.display = "none";
        bgDiv.style.display = "none";
        _setSelectDisplay("");
    };

    function _setSelectDisplay(dis) {
        var selects = document.getElementsByTagName("select");
        for (var i = 0; i < selects.length; i++) {
            selects[i].style.display = dis;
        }
    };
}

 

 

看见功能了吧。 

我想要模式窗体里的那个功能。

在我的代码的基础上。

又要麻烦你啦。

囧.......

ツ  ↘ 懒 猫的主页 ツ ↘ 懒 猫 | 初学一级 | 园豆:0
提问于:2010-11-25 11:39
< >
分享
所有回答(3)
0
<!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 language="javascript" type="text/javascript">
        /* 
        wanMessageBox弹出框 
        msg: 将要显示的信息,如果需要换行以 々 符号隔开 
        rowHeight: 每行显示的高度, 
        width:消息框的宽度 
        */

        function wanMessageBox(msg, rowHeight, width) {
            var pop = window.createPopup();

            var _msg = "";
            var arr = msg.split('々');
            var rowCount = arr.length + 1;
            for (var i = 0; i < arr.length; i++) {
                if (_msg != "") _msg += "<br /> ";
                _msg += arr[i];
            }

            var w = width;
            var h = rowCount * rowHeight + 30;
            /* */
            //居中显示 
            var l = (document.body.clientWidth - w) / 2;
            //var t = (document.body.clientHeight - h) / 2;
            var t = h / 2;
            /* 
            //显示在右下方 
    
            var l = document.body.scrollWidth - w - 1; 
            var t = document.body.clientHeight - h - 1; 
            */

            var container = document.createElement("div");

            var items = document.createElement("div");
            items.style.cssText = "z-index:50001; background:#fff;margin-top:-" + t + "px;top:50%; left:" + l + "px; width:" + w + "px; height:" + h + "px; border:4px double #99CCFF;font-size:14px; font-family:宋体;position:absolute;";
            //items.onmousedown = mousedown;

            var title = document.createElement("div");
            title.style.cssText = "width:100%; height:26px; cursor:move; line-height:26px; padding-left:5px; background:#fff; border-bottom:1px solid #99CCFF;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#99CCFF, EndColorStr=#EEF7FF);";

            var title_left = document.createElement("div");
            title_left.style.cssText = "float:left;font-weight:bold; color: #113DAE;";
            title_left.innerText = "系统消息";

            var title_right = document.createElement("div");
            title_right.style.cssText = "float:right; font-family:Webdings; font-size:16px; color: white; text-align:center; width:40px; cursor: pointer;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#F0172D, EndColorStr=#ECF5FF);";
            title_right.onclick = _hide;
            title_right.innerText = "r";

            var message = document.createElement("div");
            message.style.cssText = "padding:10px;margin:0; line-height:130%; color:black;";
            message.innerHTML = " " + _msg;

            title.appendChild(title_left);
            title.appendChild(title_right);
            items.appendChild(title);
            items.appendChild(message);
            container.appendChild(items);

            var bgDiv = document.createElement("div");
            bgDiv.style.cssText = " Z-INDEX: 50000; FILTER: alpha(opacity=50); LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 100%; BACKGROUND-COLOR: #BCBCBC; moz-opacity: 0.5; opacity: 0.5";
            bgDiv.onmouseup = function () { return false; }
            bgDiv.onmousemove = function () { return false; }
            bgDiv.onmousedown = function () { return false; }
            bgDiv.onmousedown = function () { return false; }
            bgDiv.ondblclick = function () { return false; }
            bgDiv.onclick = function () { return false; }
            bgDiv.oncontextmenu = function () { return false; }
            bgDiv.onselectstart = function () { return false; }

            document.body.appendChild(container);
            document.body.appendChild(bgDiv);

            _setSelectDisplay("none");

            var x, y, dragObj;
            function mousedown() {
                var obj = event.srcElement.parentNode;
                dragObj = obj;
                dragObj.onmousemove = mousemove;
                dragObj.onmouseup = mouseup;
                dragObj.setCapture();

                oEvent = window.event ? window.event : event;
                x = oEvent.clientX;
                y = oEvent.clientY;
            };
            function mousemove() {
                oEvent = window.event ? window.event : event;
                var _top = oEvent.clientY - y + parseInt(dragObj.style.top);
                var _left = oEvent.clientX - x + parseInt(dragObj.style.left);
                if (_left < 1) _left = 1;
                if (_top < 1) _top = 1;
                var sw = document.body.scrollWidth - dragObj.offsetWidth - 1;
                var sh = document.body.clientHeight - dragObj.offsetHeight - 1;
                if (_left > sw) _left = sw;
                if (_top > sh) _top = sh;

                try {
                    dragObj.style.top = _top + "px";
                    dragObj.style.left = _left + "px";
                }
                catch (e) { }
                x = oEvent.clientX;
                y = oEvent.clientY
            };
            function mouseup() {
                dragObj.onmousemove = null;
                dragObj.onmouseup = null;
                dragObj.releaseCapture();
                dragObj = null;
            };

            function _hide() {
                container.style.display = "none";
                bgDiv.style.display = "none";
                _setSelectDisplay("");
            };

            function _setSelectDisplay(dis) {
                var selects = document.getElementsByTagName("select");
                for (var i = 0; i < selects.length; i++) {
                    selects[i].style.display = dis;
                }
            };
        }
         

    </script>
</head>
<body>
    <p>
        <input type="button" value="点这里" onclick="wanMessageBox('你好',100,250);" />
    </p>
    <p>
        <select>
            <option>1</option>
        </select>
        <br />
        <br />
        <br />
        <br />
        <select>
            <option>2</option>
        </select>
        <br />
        <br />
        <br />
        <br />
        <select>
            <option>3</option>
        </select>
        <br />
        <br />
        <br />
        <br />
        <select>
            <option>4</option>
        </select>
    </p>
    <p>
        <br />
        <br />
        <br />
    </p>
</body>
三桂 | 园豆:3565 (老鸟四级) | 2010-11-25 13:10
自己学者去调整下...博客园没有婶婶级别的人,囧~
支持(0) 反对(0) 三桂 | 园豆:3565 (老鸟四级) | 2010-11-25 13:11
谢谢。 婶婶 囧~~
支持(0) 反对(0) ツ ↘ 懒 猫 | 园豆:0 (初学一级) | 2010-11-25 13:24
0

标题党!囧~~~~~~

刚子blog | 园豆:205 (菜鸟二级) | 2010-11-25 17:06
0

我以为是一个找人贴……~~~~~~

dongger | 园豆:9 (初学一级) | 2010-11-26 10:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册