经典论坛's Archiver

php2009 发表于 2008-5-8 12:06

有谁做过JS记录收起和展开的功能,请指教下

有谁做过JS记录收起和展开的功能,请指教下

我想点击展开,再点击缩回

因为有多个页面,所以在点一次后可以记录,请高手指教

php2009 发表于 2008-5-8 12:16

那个传说中的子虚乌有怎么不见了

好怀念啊

kabukon 发表于 2008-5-8 12:21

可以判断他的高度来升缩,也可以通过判断他的display

php2009 发表于 2008-5-8 12:43

[quote]原帖由 [i]kabukon[/i] 于 2008-5-8 12:21 发表 [url=http://bbs.blueidea.com/redirect.php?goto=findpost&pid=3990880&ptid=2853279][img]http://bbs.blueidea.com/images/common/back.gif[/img][/url]
可以判断他的高度来升缩,也可以通过判断他的display [/quote]
多谢这位神秘的高手

升缩都做好了,现在是要记录升缩状态,以便下一个页面使用同样的状态,该怎么办?

啊,发现这里的JS牛人真多啊

foxbaty 发表于 2008-5-8 13:47

三个方法
1. 通过COOKIES
2.通过HASH
3.通过WIN.NAME

也可能我只知道这三个方法  还有其他方法吧

php2009 发表于 2008-5-8 14:35

[quote]原帖由 [i]foxbaty[/i] 于 2008-5-8 13:47 发表 [url=http://bbs.blueidea.com/redirect.php?goto=findpost&pid=3991089&ptid=2853279][img]http://bbs.blueidea.com/images/common/back.gif[/img][/url]
三个方法
1. 通过COOKIES
2.通过HASH
3.通过WIN.NAME

也可能我只知道这三个方法  还有其他方法吧 [/quote]
2.通过HASH
3.通过WIN.NAME

第一种明白,后两个好象没听说过啊,又一个高手出现了啊

Idoit 发表于 2008-5-8 14:55

[html]<!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>
<style>
body{font-size:12px}
h2{margin:0;width:120px; height:22px; background:#DADADA; line-height:22px; font-size:14px; padding-left:12px; padding-right:12px; border-bottom:1px solid #fff}
div{margin:0; padding:12px; width:120px; background:#EAEAEA}
</style>
<script type="text/javascript">
function tab() {
        var tabs = document.getElementsByTagName("H2");
        var boxs = document.getElementsByTagName("DIV");
        var sId  = readCookie("sId");
        if (sId == "" || sId == "null") sId = null;
       
        for (var i=0; i<tabs.length; i++) {
                if ( i != sId ) boxs[i].style.display = "none";
                setClick(i);
        }
       
        function setClick(num) {
                tabs[i].onclick = function() {
               
                        if (sId != num ) {
                                if (typeof sId != "undefined" && sId != null) boxs[sId].style.display = "none";
                                sId = num;
                                boxs[sId].style.display = "block";
                        } else {
                                boxs[sId].style.display = "none";
                                sId = null;       
                        }
                        writeCookie("sId", sId);
                }
        }
}

function readCookie(l){
        var i="",I=l+"=";
        if(document.cookie.length>0){
                offset=document.cookie.indexOf(I);
                if(offset!=-1){
                        offset+=I.length;
                        end=document.cookie.indexOf(";",offset);
                        if(end==-1)end=document.cookie.length;
                        i=unescape(document.cookie.substring(offset,end))
                }
        }
        return i;
}
function writeCookie(O,o){
        document.cookie=O+"="+escape(o);
}


window.onload = tab;
</script>
</head>

<body>
<h2>菜单1</h2>
<div>菜单1内容</div>
<h2>菜单2</h2>
<div>菜单2内容</div>
<h2>菜单3</h2>
<div>菜单3内容</div>
</body>
</html>
[/html]

AllanWang 发表于 2008-6-10 02:07

LZ拿到现成代码就不回复,此人。。。:o

wuleying 发表于 2008-6-10 09:47

[url]http://www.qqdang.net/code/windowsMenu/[/url]

右键->源代码

liupei123 发表于 2008-8-29 12:22

我怎么定位呀
我想把他放到一个容器中。放进去就不会显示了

页: [1]



Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.