recently i have seen following error in jsfiddle document.write is disallowed in JSFiddle envioriment and might break your fiddle
. Why JSfiddle has banned document.write
? What are the major side effects of using this? and what are the best alternatives of this?
Asked
Active
Viewed 73 times
1
-
3`document.write` can have problems with race conditions and, if the document is finished being written, will trigger `document.open` - clearing the whole page of all _HTML_. Alternatives? Use _DOM methods_ such as `appendChild`. – Paul S. Feb 02 '14 at 23:15
-
So if added the document.write("something") in my code, it will auto trigger the document.open and my whole code will be erased? – Feb 02 '14 at 23:18
-
You may find it helpful to read the MDN page on this method https://developer.mozilla.org/en-US/docs/Web/API/document.write – Paul S. Feb 02 '14 at 23:24