Javascript getElementById null error

前端 未结 1 592
你的背包
你的背包 2021-01-26 05:59

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

相关标签:
1条回答
  • 2021-01-26 06:33

    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 of document.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.open statement in the GenerateCoord function. That clears the complete document, after which - indeed - no element is left to get by any Id. Here's a jsfiddle without it.

    0 讨论(0)
提交回复
热议问题