Adding global variables in html and javascript: html global reproduces issue, javascript does not