Solved

Hide a Div As a Session State - after Div is hidden it remains hidden on subsequent pages

Posted on 2010-09-15
3
438 Views
Last Modified: 2012-05-10
I'm new to JS and jQuery.. I have "all" the books and am doing my home work.  But some things are still opaque. I will be putting a banner across the tops of all pages on a site for 3 months, I'll bring in this one code chunk using SSI and banners will change, but we want to put a "Hide" button on it so if some user wants to turn it off for the current session, he can. I don't want to store that as a preference in a cookie, but only for the current session.  

OK, now, the animate tool in jQuery is quite transparent and the documentation in the jQuery Cookbook, which I have is also very simple. BUT:  if I implement this on one page, when the user goes to the next page, the div will appear again. How do I trap the banner state? In effect, make "display:none"  "sticky", as the user traverses many pages.  I will go and see if I can study up on sessions, but I have a short time frame to get this done and I'm not sure I'll grok everything on time.  Any help will be appreciated.
0
Comment
Question by:Sivakatirswami
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Expert Comment

by:wellhole
ID: 33684746
One easy way is to use a session only cookie.
0
 
LVL 2

Accepted Solution

by:
WilliamStam earned 500 total points
ID: 33711105
checkout the jQuery cookie plugin.. theres a session only cookie option (when you dont set an expiry date thing)

on click set the session cookie.. then just have a if session cookie == "thisNthat" then hide banner

session state cookies are the same as a server side session..

http://plugins.jquery.com/files/jquery.cookie.js.txt

$("#hidebtn").click(function(){
$.cookie('the_cookie', 'hideme');
});

if ( $.cookie('the_cookie') == "hideme" ){
$("#banner").addClass("showthebannerclass");
};

since the cookie is set... maybe use a server side cookie check.. otherwise the page will load normaly then when it gets to running the js it will suddenly hide it..
0
 
LVL 2

Expert Comment

by:WilliamStam
ID: 33711107
other options is to maybe use a query string... but you better off with the session route
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jQuery Sticky Menu 24 42
jQuery Dialog Autoresize Bug 2 33
jQuery on click requires double click 6 34
JQuery conflicts/syntax issue 4 25
Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question