简体   繁体   中英

Manipulating two html files with one JavaScript file

I'm trying to make a simple game using html and javascript, I have my index page which prompts the user for the number of players, then I would want to display as many input fields as the players' number. My problem now is that when the user types in a number, he gets redirected to another html page to insert the names, I need the players number value , but I can't seem to get it right, as when I try to use the same app.js file for the two html pages it doesn't work.

You can use localStorage: localStorage.set('example','data');

then in page two: console.log(localStorage.get('example'));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM