This page contains an OL game (One Line game): a full messaging board made using
only one line of HTML with JavaScript inside it. It uses your browser’s
localStorage, so it even works without internet once loaded.
When you click the button, a popup will appear asking for your username. Type any name you want to use and press OK.
After entering your username, you will be asked to type send or
view:
If you choose send, you will be asked to type your message.
You can use some special tricks:
/n: creates a new line in your message/t: adds a space (tab style)/rollX: rolls a dice with X sides, for example /roll20After you send your message, the board will show all messages in one big popup. Each line has the date, time, username, and message.
The button has JavaScript inside its onclick attribute. When you click it,
the script:
localStorage.user.localStorage.board (or creates an empty one)./n, /t, and /roll, then adds a timestamp.localStorage and shows everything in an alert.(if your friend says they put a message and you don't see it, refresh the page.)
You can make your own OL game by creating a single <button> with all the
JavaScript inside the onclick attribute, just like this one. Here’s a simple
template to start from:
<button onclick="alert('Hello from my OL game!');">My OL Game</button>
From there, you can:
prompt('Question') to ask the player things.localStorage.key = value to remember things.JSON.stringify and JSON.parse.if statements to react to what the player types.Have fun making your own OL games and message boards!