0

I have two JavaScript classes/files, and two html pages:

-month.html
-month.js
-day.html
-day.js

I am trying to figure out how to pass a value from one html/js to the other. For instance, when a user clicks on a date in the month.html, I would like to pass that value from month.js to day.js and then display it on the day.html. Is there a quick way that I can just pass a date to the day.html and then work with it in day.js?

Thanks!

2
  • 2
    at least 3: url parameters, cookies, localstorage Commented Mar 12, 2014 at 13:27
  • 1
    one more to add you can carry session data.. Commented Mar 12, 2014 at 13:30

1 Answer 1

2

I would suggest using a cookie or localStorage for this purpose.

If using localStorage in month.js do:

localStorage.setItem('date', date);

and in day.js retrieve the date with:

var date = localStorage.getItem('date');

Keep in mind, that localStorage is not supported in older browsers. You can read more about alternative local storage methods here: http://diveintohtml5.info/storage.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.