Why document.writeln is considered bad practice
When debugging JavaScript code on pages Console sometimes complains about the use of document.writeln().
I used this in my footer to echo the date and time that the page was last changed. I also don't know why the document.writeln() only works if it enclosed within comment code and on a new line.
The code that I changed:
<A HREF="#top"><SCRIPT><!--
document.writeln(document.lastModified)
--></SCRIPT></A>
was changed to:
<script>
document.getElementById("code").innerHTML = document.lastModified;
</script>
In addition if you click on the top-most code snippet it will change the section heading text. Also notice that the cursor will change to a pointer if placed over the snippet.
So why is it bad-practice?
In short - code injection.....
Last modified:-