I posted quite recently about an issue with javascript in firefox, and it was denoted the problem was likely document.write() overwriting the script somehow. It was suggested I use IDs to solve the problem of both overwriting the script and to avoid stacking of the information.
However, on trying to implement the IDs into my javascript and html code, I found that firebug reports that:
"TypeError: document.getElementById("author_container") is null"
Despite the fact, that, once again, the ID is already defined under:
<p id="author_container"></p>
And there are clearly no typos, and re-arranging the script into the head section or altering it so the p occurs before the script makes absolutely no difference. (Note the other example runs fine despite the script occurring first).
If I use a pre-existing example of an ID and getElementById and run it in firefox, it runs fine:
But if I try to run my code, which doesn’t seem that majorly different, I run into issues:
http://pastebin.com/XfGUpZAS
Am I missing something here? How do I alter the code to make it work in firefox? Will firefox allow me to ever run my code correctly? (Find out next week?)
Place your script at the bottom of the page, right before the closing
</body>tag. In other words, make the script tag the last one ofdocument.body. That way the DOM-tree is completely loaded before the scripting starts.Aside from a number of issues, the real issue is the
document.openstatement in theGenerateCoordfunction. That clears the complete document, after which – indeed – no element is left to get by any Id. Here’s a jsfiddle without it.