再开 100 分贴:只差一丁点了,我用javascript和div 实现的无刷新隐藏与显示 div 层的功能已实现,就是不知道当有刷新或回发的时候,页面
pub.aspx 页全部代码如下:
-------------------------------------------------
<script>
function displayDiv(obj)
{
if(document.getElementById( "divOrders ").style.display== "none ")
{
document.getElementById( "divOrders ").style.display= "block ";
document.getElementById( "btnDisplay ").value= "隐藏 ";
}
else
{
document.getElementById( "divOrders ").style.display= "none ";
document.getElementById( "btnDisplay ").value= "显示 ";
}
}
</script>
<body >
<form id= "Form1 " method= "post " runat= "server ">
<table>
<tr>
<td> <input type= "button " name= "btnDisplay " value= "隐藏 " onclick= "displayDiv(document.getElementById( 'divOrders ')) ">
<div id= "divOrders " style= "DISPLAY:none ">
<table width= "95% " align= "center " height= "300 ">
<tr>
<td bgColor= "#66cc33 "> 这里是工作单内容
<asp:Button id= "Button1 " runat= "server " Text= "测试回发后是否能保持住状态 "> </asp:Button>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</form>
</body>
--------------------
如何能实现我说的功能:假如我现在是通过点击
<input type= "button " name= "btnDisplay " value= "隐藏 " onclick= "displayDiv(document.getElementById( 'divOrders ')) ">
按钮,把 <div id= "divOrders " style= "DISPLAY:none "> 层隐藏或是显示了,当这个页面上刷新或是有回发的时候,如何能够保持住当前页面的状态(隐藏或是显示的状态)
再一次请各位高手帮忙!不胜感激!!!
------解决方案--------------------每次改变后把值放到cookie中,刷新后从cookie取值判断。
只是想法,没试过。
------解决方案-------------------- <script>
function displayDiv(obj)
{
if(document.getElementById( "divOrders ").style.display== "none ")
{
document.getElementById( "divOrders ").style.display= "block ";
document.getElementById( "btnDisplay ").value= "隐藏 ";
}
else
{
document.getElementById( "divOrders ").style.display= "none ";
document.getElementById( "btnDisplay ").value= "显示 ";
}
document.cookie = 'curp= ' + document.getElementById( "divOrders ").style.display;
}
</script>
<body >
<form id= "Form1 " method= "post " runat= "server ">
<table>
<tr>
<td> <input type= "button " name= "btnDisplay " value= "隐藏 " onclick= "displayDiv(document.getElementById( 'divOrders ')) ">
<div id= "divOrders " style= "DISPLAY:none ">
<table width= "95% " align= "center " height= "300 ">
<tr>