See the answer. JavaScript DOM Manipulation, addEventListener, etc Not Working. So for some reason it is not working and errors are getting generated now so I google around and I can't figure this out so how can I keep the code pretty much the same with a small enough changes to make it work with ..DOMContentLoaded..? I have the following code which works fine on most browsers. The IE 8 and older versions use the attachEvent function. I have this code in my HTML file: