code001 Posted January 8, 2021 Share Posted January 8, 2021 in Tryit Editor v3.6 (w3schools.com) (the URL in the link is different than the following one) the statment "document.write" is called by an event and it behaves in a different way than in Tryit Editor v3.6 (w3schools.com) (different URL than previous). In the first test the statement impacts the whole document while in the second one the tag SCRIPT put the statement in the flow, insulating it inside an element of the object DOCUMENT I have anderstood the difference, but... ... does anyone be able to sketch the proper sequence of the document elaboration in both cases to explain what produces the difference? THanks in advance Link to comment Share on other sites More sharing options...
Ingolme Posted January 8, 2021 Share Posted January 8, 2021 In general, document.write() shouldn't be used. Alternatives to document.write() are element.innerHTML to add or modify content and console.log() for testing. When called during page load, it will insert the content into the place it was called from. If called after the page has finished loading, it replaces the page with new content. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now