0

I made 2 html files, one is mainly using javascript,(the index). And another that is for the info. So in the index.html file when opened it displays a main menu and a button called books and when clicked on it displays a list of book titles and etc. and when chosen one of them it will send you to the 2nd html file, the info.html file. I made a button on the info.html file where it will send you back to the index.html file, but when i click on it goes back to the main menu screen and not the books list screen.

Is there anyway to have the current state of the previous html file stay the same?

(I made the mainmenu dissapear and books tab reappear using javascript.)

NukY
  • 33
  • 6

1 Answers1

1

When user navigated from Page 2 (info.html) to Page 1 (index.html) using back button, you need some identifier to trigger same functionality which you are triggering on Books button click to displays a list of book titles and etc.

So technically, you need to add a query string identifier on link of Back button

i.e <a href="/index.html?back=1"> Back </a>

Now, read value of query string identifier in javascript of index.html and conditionally trigger the same functionality which your are triggering when user click on Books button.

Tanmay
  • 1,123
  • 1
  • 10
  • 20
  • Thx alot for replying, but i still dont quite understand though. heres a fiddle i made for index:https://jsfiddle.net/vu9qbtxq/10/ **(for some reason js is not working but i think you get what i mean)** and heres the info https://jsfiddle.net/rkemr3x4/1/** – NukY Feb 16 '18 at 17:29
  • soo have u gotten it? – NukY Feb 18 '18 at 15:21
  • @NukY Here is your updated index.html - https://jsfiddle.net/vu9qbtxq/18/ . And Info.html - https://jsfiddle.net/rkemr3x4/7/ . Hope this will help you. – Tanmay Feb 19 '18 at 09:39
  • one curious qs but why was my fiddle's javascript not working? – NukY Feb 22 '18 at 17:30
  • @NukY This is because function name `books` conflicts with div id `books`. For more info refer [this](https://stackoverflow.com/questions/9158238/why-js-function-name-conflicts-with-element-id) . – Tanmay Feb 23 '18 at 10:46
  • THX YOUUU AGEN!! – NukY Feb 24 '18 at 03:35