Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-09-15
3
Medium Priority
?
444 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
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)
Suggested Courses

636 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