Jump to content

Recommended Posts

Posted

We've got an Intranet here which I've put a button on today to drop down a BBC News RSS feed (fancy I know).

What I want to do, is have the machine remember the last state the button was in.

 

So, if student A goes to the Intranet and presses 'Show BBC News Feed', when they come back to the Intranet later, it should automatically show.

However, if they then press 'Hide BBC News Feed' it should remember that they hid it.

 

Any ideas?

 

PS - I'm not HTML/JavaScript/JQuery genius, so please be patient!

Posted
PS - I'm not HTML/JavaScript/JQuery genius, so please be patient!

 

Genius knowledge probably not required for this so don't worry - It's pretty straightforward.

 

The easiest way to 'remember' information such as this between page loads is to save a cookie containing the information to the user's computer. You can then read the value of this cookie when the page next loads.

 

In you case, whenever the user clicks your button you could run some Javascript to save the state of the feed to a cookie. When your page loads run some Javascript to read this cookie if it exists and set the initial state of the feed accordingly. I assume you are already using JS to toggle the display of the feed so it should be simple enough to include code to write the cookie within this.

 

Rather than just give you the code, try working through this tutorial JavaScript Cookies which starts from the very basics which will probably be more useful to you than just copying some code across. If you're still struggling paste what code you have written and I'll try to help more - Sound fair? :eyebrows:

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...