Oh gosh, I can't believe I missed this. No, please do not construct HTML in the JS. You're gonna run into security issues that way.    Perhaps take a look at how it's done in the exploration history tab?