JS仿iGoogle自定义首页模块拖拽特效的方法(11)

window.onload = function() {
            var dragTbl = document.getElementById("dragTable");
            if (Common.getCookie("configArr")) {
                var configArr = eval("(" + Common.getCookie("configArr") + ")");
                for (i = 0; i < dragTbl.rows[0].cells.length; i++) {
                    for (j = 0; j < configArr[i].length; j++) {
                        dragTbl.rows[0].cells[i].appendChild(document.getElementById(configArr[i][j]));
                    }
                }
            }
            new Drag("titleBar1", "dragDiv1");
            new Drag("titleBar2", "dragDiv2");
            new Drag("titleBar3", "dragDiv3");
            new Drag("titleBar4", "dragDiv4");
            new Drag("titleBar5", "dragDiv5");
        }

window.onunload = function() {
            var dragTbl = document.getElementById("dragTable");
            var configArr = "";
            for (i = 0; i < dragTbl.rows[0].cells.length; i++) {
                var tmpStr = "";
                for (j = 0; j < dragTbl.rows[0].cells[i].getElementsByTagName("DIV").length; j++) {
                    tmpStr += (tmpStr == "" ? "" : ",") + "'" + dragTbl.rows[0].cells[i].getElementsByTagName("DIV")[j].id + "'";
                }
                configArr += (configArr == "" ? "" : ",") + "[" + tmpStr + "]";
            }
            //format like: [['dragDiv3','dragDiv5'],['dragDiv4','dragDiv1'],['dragDiv2']]
            Common.setCookie("configArr", "[" + configArr + "]");           
        }
    </script>
    <style type="text/css">
    .spanDiv{
    position:relative;
    width:5px;
    height:5px;
    }

.dragDiv,.nodragDiv{
    position:relative;
    filter:alpha(opacity=100);
    opacity:1;
    margin-bottom:6px;
    background-color:#FFFFFF;
    }
    </style>
</head>
<body >
<script type="text/javascript">

</script>  
    <table cellpadding="3" >
        <tr>
            <td valign="top">
                <div >
                    <table cellpadding="0" cellspacing="0">
                        <tr >
                            <th unselectable="on" >Title1</th>
                        </tr>
                        <tr valign="top" >
                            <td unselectable="on">这里的字比较长....我来了....中国....中国...外国.,看一下有没有溢出></td>
                        </tr>
                    </table>
                </div>              
                <div>
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <th unselectable="on" >Title2</th>
                        </tr>
                        <tr valign="top" >
                            <td unselectable="on">Content2...</td>
                        </tr>
                    </table>
                </div>
            </td>
            <td valign="top">
                <div>
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <th unselectable="on" >Title3</th>
                        </tr>
                        <tr valign="top" >
                            <td unselectable="on">Content3...</td>
                        </tr>
                    </table>
                </div>               
            </td>
            <td valign="top">
                <div>
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <th unselectable="on" >Title4</th>
                        </tr>
                        <tr valign="top" >
                            <td unselectable="on">Content4...</td>
                        </tr>
                    </table>
                </div>
                <div>
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <th unselectable="on" >Title5</th>
                        </tr>
                        <tr valign="top" >
                            <td unselectable="on">Content5...</td>
                        </tr>
                    </table>
                </div>
            </td>
        </tr>   
    </table>
</body>
</html>

<br><br><hr> 收集于互联网,只为兴趣与学习交流,不作商业用途。</font></p>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgffxd.html