I have the following script which slides in/slide out a DIV from the right:
// jQuery 1.9 > Toggle Event dep 1.8
$('#slideClick').click(function () {
var it = $(this).data('it') || 1;
switch (it) {
case 1:
$(this).parent().animate({ right: '-290px' }, { queue: false, duration: 500 });
$("#imgArrow").attr("src", "../theImages/arrow_expand.png");
break;
case 2:
$(this).parent().animate({ right: '-0px' }, { queue: false, duration: 500 });
$("#imgArrow").attr("src", "../theImages/arrow_collapse.png");
break;
}
it++;
if (it > 2) it = 1;
$(this).data('it', it);
});
The HTML code in the MasterPage which corresponds to the above script is:
<div id="slideOut" class="clearfix">
<div id="slideContent">
<div style="width: 98%; margin: 0 auto; padding: 5px;">
<div id="dvImpMsgs" style="padding-left: 10px; padding-right: 10px;">
<asp:UpdatePanel runat="server" ID="upMessage" ClientIDMode="Static" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblMessage" Font-Size="x-small" runat="server" Text="" ClientIDMode="Static"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
<div id="slideClick">
<div style="padding: 0; margin: 0 auto; width: 100%; height: 100%; text-align: center;">
<div class="arrowMsg">
<img src="../theImages/arrow_collapse.png" id="imgArrow" style="width: 12px; height: 18px; border: 0; vertical-align: middle;" />
</div>
<div style="width: 80px; height: 50px; float: right; margin: 0; padding: 0;">
<div style="width: 80px; height: 30px; text-align: center; line-height: 30px; vertical-align: middle;" class="brClear">
<img src="../theImages/iMsg.png" style="width: 30px; height: 30px; border: 0" />
</div>
<div style="color: #FFFFFF; width: 80px; height: 20px; text-align: center; line-height: 20px; vertical-align: middle; font-size: 10px;" class="brClear">
MESSAGES
</div>
</div>
</div>
</div>
</div>
Everytime a user visits the page the slide-out is true which forces the user to click the slideclick
DIV to close it, which can get a unfriendly to the user.
How can I use a cookie or session so the following can happen:
The first time a user visits show the DIV in slide-out position, once they click the slideclick
DIV to hide. It will continue to remain hidden from the user until the browser is closed, in which case once the user re-opens the browser again, the DIV should be in slide-out position until the user click the slideclick
DIV to hide, and so forth.
slide-out position:
hide position: