Answer:
I created a jsfiddle for this: https://jsfiddle.net/tonb/o7uv4cdm/26/
Explanation:
see jsfiddle.
The usual html and body tags are omitted for simplicity. For your stand-alone page you'll have to put them in, as well as additional tags for your inline scripting.