foo() {
var fooVar=7;
location.assign("otherPage.php");
otherPageobject.html=fooVar;
}
Asked
Active
Viewed 23 times
0

David
- 208,112
- 36
- 198
- 279
-
You can't. Imagine the security risk if you directed the user to e.g. a banking website and then injected your own HTML into that page. – Geat Jul 07 '20 at 16:11
1 Answers
0
The code running on one page can't affect anything on another page, because only one page can be loaded/active at a time. What you can do is send your value to that next page. For example:
location.assign("otherPage.php?fooVar=" + fooVar);
Then in that other page you can get the value from the query string and use it as you see fit.

David
- 208,112
- 36
- 198
- 279