主页有A B C三个层,默认首先显示是A层,当我现显示B层后,点击B层的按键后,主页又显示A层了,我想显示的是B层,同样,当我显示C层后,在主页不管怎样操作都是显示C层,除非点击A层或关闭主页.这就是我想要的.
解决方案 »
- 网页弹出框问题
- 哪位有.net顶部菜单的实例
- 各位网友好,过来看看我做的这个网站能值多少钱。
- 我在做测试的时候以最快的速度点击测试页面中的连接,出现以下错误,请指教,谢谢.
- SqlHelper的问题:CreateCommand和FillDataset方法的代码在哪里?
- 我想将一个string类型的字符串(>4000字节)插入到oracle数据库中的clob字段中去,该如何操作呢?(c#)
- RangeValidator验证控件问题
- 然后用LINKBUTTON建立超链接啊!急!
- 请多指教,在线等待,谢谢!
- sqlConnection能连接ACCESS数据库吗??要怎样才能实现。
- 图片显示的问题
- 谁给推荐一个比较好的内容管理系统
给你我写的一个组件 就是实现展开收缩功能的
//
// Usage:
// onclick=Collapsable.Initial('id1','id2','cssclass1','cssclass2',false);
// 如果要保存视图状态,则在页面加载的时候需要还原试图状态 Collpasagle.LoadViewState()
// Depend:
// System.Cookie {System.js};
//
//-----------------------------------------------------------------------//var Collapsable={
//false表示正常显示的,还没有折叠起来,true表示已经折叠起来了
IsCollapse:false,
Target:null,
Sender:null,
//senderid表示点击的对象ID
//targetid表示要隐藏的对象ID
//senderCssName表示正常情况下的CssClass
//senderCssName1表示折叠起来的时候CssClass
//isSaveViewState 表示是否要保存折叠状态,默认是保存状态
Initial:function(senderid,targetid,senderCssName,senderCssName1,isSaveViewState)
{
this.Target=$(targetid);
this.Sender=$(senderid); if(this.Target.style.display=="none")
this.IsCollapse=true;
else
this.IsCollapse=false;
if(this.IsCollapse)
{
this.Target.style.display="block";
this.Sender.className=senderCssName;
}
else
{
this.Target.style.display="none";
this.Sender.className=senderCssName1;
System.Cookie.SetCookie(targetid,senderid);
}
this.IsCollapse=this.IsCollapse?false:true;
if(!isSaveViewState||isSaveViewState)
this.SaveViewState(senderid,senderCssName1,targetid,this.IsCollapse);
return this.IsCollapse;
},
///还原视图状态
LoadViewState:function()
{
var cookie=System.Cookie.GetCookie("collpanel");
if(cookie)
{
var list=cookie.split("#");
for(var i=0;i<list.length;i++)
{
var data=list[i].split('|');
if($(data[0])&&$(data[2])&&data[3]&&data[3]=="true")
{
$(data[2]).style.display="none";
$(data[0]).className=eval('data[1]');
}
}
}
},
//senderId,sender在收缩状态的cssClass,目标Id,目标id的收缩状态{true,false}
SaveViewState:function(senderid,senderCssName1,targetid,targetColl)
{
var cookie=System.Cookie.GetCookie("collpanel");
var newcookie=new Array();
if(cookie)
{
var list=cookie.split("#");
for(var i=0;i<list.length;i++)
{
var data=list[i].split('|');
if(data[0]==senderid)
continue;
else
{
newcookie[newcookie.length]=list[i];
}
}
newcookie[newcookie.length]=senderid+"|"+senderCssName1+"|"+targetid+"|"+targetColl;
cookie=newcookie.join('#');
}
else
{
cookie=senderid+"|"+senderCssName1+"|"+targetid+"|"+targetColl;
}
System.Cookie.SetCookie("collpanel",cookie);
}
}var System=System?System:{};System.Cookie=
{
// Create a cookie with the specified name and value.The cookie expires at the end of the 20th century.
SetCookie:function(sName, sValue)
{
date = new Date();
document.cookie = sName + "=" + escape(sValue) + ";";
},
// Retrieve the value of the cookie with the specified name.
GetCookie:function(sName)
{
// cookies are separated by semicolons
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
// a name/value pair (a crumb) is separated by an equal sign
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
return null;
},
// Delete the cookie with the specified name.
DelCookie:function(sName)
{
document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}
}
主页有A B 二个层,默认显示是A层,当我点击菜单显示B层后,接着点击B层表格里的的提交按键,主页又显示A层了,我想显示的是B层.
也可以用url上加标志显示哪个曾
还可以用无刷新的来做.
javascript:
<!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>
<title>网页特效|Linkweb.cn/Js|---用层模拟的小窗口(可拖动展合)</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type='text/css'>
<!--
body{font-size:12px;}
a:visited{text-decoration:none;color:slategray;}
a:hover{text-decoration:underline;color:slategray;}
a:link{text-decoration:none;color:slategray;}
-->
</style> <script language="JScript">
<!--
//可以打包为js文件;
var x0=0,y0=0,x1=0,y1=0;
var offx=6,offy=6;
var moveable=false;
var hover='orange',normal='#336699';//color;
var index=10000;//z-index;
//开始拖动;
function startDrag(obj)
{
//debugger
if(event.button==1)
{
//锁定标题栏;
obj.setCapture();
//定义对象;
var win = obj.parentNode;
var sha = win.nextSibling;
//记录鼠标和层位置;
x0 = event.clientX;
y0 = event.clientY;
x1 = parseInt(win.style.left);
y1 = parseInt(win.style.top);
//记录颜色;
normal = obj.style.backgroundColor;
//改变风格;
obj.style.backgroundColor = hover;
win.style.borderColor = hover;
obj.nextSibling.style.color = hover;
sha.style.left = x1 + offx;
sha.style.top = y1 + offy;
moveable = true;
}
}
//拖动;
function drag(obj)
{
//debugger
if(moveable)
{
var win = obj.parentNode;
var sha = win.nextSibling;
win.style.left = x1 + event.clientX - x0;
win.style.top = y1 + event.clientY - y0;
sha.style.left = parseInt(win.style.left) + offx;
sha.style.top = parseInt(win.style.top) + offy;
}
}
//停止拖动;
function stopDrag(obj)
{
//debugger
if(moveable)
{
var win = obj.parentNode;
var sha = win.nextSibling;
var msg = obj.nextSibling;
win.style.borderColor = normal;
obj.style.backgroundColor = normal;
msg.style.color = normal;
sha.style.left = obj.parentNode.style.left;
sha.style.top = obj.parentNode.style.top;
obj.releaseCapture();
moveable = false;
}
}
//获得焦点;
function getFocus(obj)
{
//debugger
if(obj.style.zIndex!=index)
{
index = index + 2;
var idx = index;
obj.style.zIndex=idx;
obj.nextSibling.style.zIndex=idx-1;
}
}
//最小化;
function min(obj)
{
//debugger
var win = obj.parentNode.parentNode;
var sha = win.nextSibling;
var tit = obj.parentNode;
var msg = tit.nextSibling;
var flg = msg.style.display=="none";
if(flg)
{
win.style.height = parseInt(msg.style.height) + parseInt(tit.style.height) + 2*2;
sha.style.height = win.style.height;
msg.style.display = "block";
obj.innerHTML = "0";
}
else
{
win.style.height = parseInt(tit.style.height) + 2*2;
sha.style.height = win.style.height;
obj.innerHTML = "2";
msg.style.display = "none";
}
}
//创建一个对象;
function xWin(id,w,h,l,t,tit,msg)
{
//debugger
index = index+2;
this.id = id;
this.width = w;
this.height = h;
this.left = l;
this.top = t;
this.zIndex = index;
this.title = tit;
this.message = msg;
this.obj = null;
this.bulid = bulid;
this.bulid();
}
//初始化;
function bulid()
{
//debugger
var str = ""
+ "<div id=xMsg" + this.id + " "
+ "style='"
+ "z-index:" + this.zIndex + ";"
+ "width:" + this.width + ";"
+ "height:" + this.height + ";"
+ "left:" + this.left + ";"
+ "top:" + this.top + ";"
+ "background-color:" + normal + ";"
+ "color:" + normal + ";"
+ "font-size:8pt;"
+ "font-family:Tahoma;"
+ "position:absolute;"
+ "cursor:default;"
+ "border:2px solid " + normal + ";"
+ "' "
+ "onmousedown='getFocus(this)'>"
+ "<div "
+ "style='"
+ "background-color:" + normal + ";"
+ "width:" + (this.width-2*2) + ";"
+ "height:20;"
+ "color:white;"
+ "' "
+ "onmousedown='startDrag(this)' "
+ "onmouseup='stopDrag(this)' "
+ "onmousemove='drag(this)' "
+ "ondblclick='min(this.childNodes[1])'"
+ ">"
+ "<span style='width:" + (this.width-2*12-4) + ";padding-left:3px;'>" + this.title + "</span>"
+ "<span style='width:12;border-width:0px;color:white;font-family:webdings;' onclick='min(this)'>0</span>"
+ "<span style='width:12;border-width:0px;color:white;font-family:webdings;' onclick='ShowHide(\""+this.id+"\",null)'>r</span>"
+ "</div>"
+ "<div style='"
+ "width:100%;"
+ "height:" + (this.height-20-4) + ";"
+ "background-color:white;"
+ "line-height:14px;"
+ "word-break:break-all;"
+ "padding:3px;"
+ "'>" + this.message + "</div>"
+ "</div>"
+ "<div id=xMsg" + this.id + "bg style='"
+ "width:" + this.width + ";"
+ "height:" + this.height + ";"
+ "top:" + this.top + ";"
+ "left:" + this.left + ";"
+ "z-index:" + (this.zIndex-1) + ";"
+ "position:absolute;"
+ "background-color:black;"
+ "filter:alpha(opacity=40);"
+ "'></div>";
document.body.insertAdjacentHTML("beforeEnd",str);
}
//显示隐藏窗口
function ShowHide(id,dis){
//debugger
var bdisplay = (dis==null)?((document.getElementById("xMsg"+id).style.display=="")?"none":""):dis
document.getElementById("xMsg"+id).style.display = bdisplay;
document.getElementById("xMsg"+id+"bg").style.display = bdisplay;
}
//modify by haiwa @ 2005-7-14
//
//-->
</script> <script language='JScript'>
<!--
function initialize()
{
//debugger
var a = new xWin("1",160,200,200,200,"窗口1","xWin <br> A Cool Pop Div Window<br>Version:1.0<br>2002-8-13");
var b = new xWin("2",240,200,100,100,"窗口2","Welcome to visited my personal website:<br><a href=http://linkweb.cn/js target=_blank>http://linkweb.cn/js</a><br>and u can also sign my guestbook at:<br><a href=http://linkweb.cn/Js/GBook/Index.php target=_blank>http://linkweb.cn/Js/GBook/Index.php</a><br><br>...");
var c = new xWin("3",200,160,250,50,"窗口3","Copyright by <a href='mailto:[email protected]'>LinkWeb.cN</a>!");
ShowHide("1","none");//隐藏窗口1
}
window.onload = initialize;
//-->
</script></head>
<base target="_blank" />
<body onselectstart='return false' oncontextmenu='return false'>
<a onclick="ShowHide('1',null);return false;" href="">窗口1</a> <a onclick="ShowHide('2',null);return false;"
href="">窗口2</a> <a onclick="ShowHide('3',null);return false;" href="">窗口3</a>
</body>
</html>