0

Let's say I declared the variable var = 5; in frame1. Now how do I pass this variable to frame2? I'd like to pass it using a hyperlink. Are there any other ways to do that?

Also, how do I access that variable after passing to frame2 in frame2?

Rikki
  • 3,338
  • 1
  • 22
  • 34

1 Answers1

1

You could use a query string. You could set the link in JavaScript like this:

var a = document.getElementById('linkId');
a.href = "link?var=" + var;

You would have to run this code each time you change your variable.

If you need to parse the query string I would refer to this post: How can I get query string values in JavaScript?

Community
  • 1
  • 1
Niles Tanner
  • 3,911
  • 2
  • 17
  • 29