Author | Message |
---|---|
lefeng96
Posts: 6
|
Posted 17:42 Feb 13, 2017 |
The page will always loads the script first then display the text from document.write. How do I fix this? |
amclees2
Posts: 12
|
Posted 22:18 Feb 13, 2017 |
I am not sure exactly what the issue is with the script being loaded before displaying the document.write text. In order for the document.write method to be called, the browser needs to have loaded the script. Two things to try:
If you could describe the problem in more detail, I might have more suggestions. |
lefeng96
Posts: 6
|
Posted 00:17 Feb 14, 2017 |
The problem is that we have to display user HP, prizes and other details but document.write would only show them at the end which isn't helpful for users |
amclees2
Posts: 12
|
Posted 09:09 Feb 14, 2017 |
If you want to scroll to where the text has been added:
The above code will scroll to the bottom of the page by scrolling the full height of the document.body. It will let you show the user your document.write info. You could also look at my answer here and try the one with document.body.innerHTML. That would allow you to write to the top of the page instead. If you do that, be sure to put your script tag in the body of your HTML page. |