Jump to content

full page tabs

Recommended Posts


I am new here. I have made a page with the "full page tabs". There are forms on the pages.

Instead of using the id="defaultOpen" I would like the last visited page to re-open after refresh.

I have tried several methods like cookies, session variables and hidden inputs, but it does not give the preferred result.

Is there a solution to this "problem"?




Link to post
Share on other sites

Thank you for your reply.

I tried that method, but the problem is that all pages are accessed at each refresh, even the ones not active. This results in that the code always get the storage given by the sequentially (in the code) last page.

Same goes for all other methods I mentioned.

Referring to the examples, all four are executed!:

<div id="Home" class="tabcontent">
  <p>Home is where the heart is..</p>

<div id="News" class="tabcontent">
  <p>Some news this fine day!</p>

<div id="Contact" class="tabcontent">
  <p>Get in touch, or swing by for a cup of coffee.</p>

<div id="About" class="tabcontent">
  <p>Who we are and what we do.</p>

---- The last in the coding sequence will always be the one storing its specific details in the webstorage.

As a result, it does not work that way.



Link to post
Share on other sites

Depending how you make the selected tab active? you should use event such as 'click' to store the value of "Contact", which at the same time clearing ANY current  pages using "active" class and then a 'active' class to the element with id "Contact", All the others should be hidden by default so the active class will make makes it visible, you would at first check if webstorage is empty, then set first i.e id "Home" as having class "active".

Link to post
Share on other sites

Sorry for delay, had a lot of other things to do.

I understand your reply and will try it as soon as I have the opportunity.

Will let you know.

However, if you can suggest how to store any session variable in the standard scriptroutine, I'd be very grateful.

I am using this function, directly copied from W3Schools:

function openPage(pageName,elmnt,color) {
var i, tabcontent, tablinks;

**** I suppose I would have to add code here ****

tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent.style.display = "none";
tablinks = document.getElementsByClassName("tablink");
for (i = 0; i < tablinks.length; i++) {
tablinks.style.backgroundColor = "";
document.getElementById(pageName).style.display = "block";
elmnt.style.backgroundColor = color;

// Get the element with id="defaultOpen" and click on it



Edited by KamauM
part of message did not publish
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...