Home >Web Front-end >JS Tutorial >Example of using document.write to output content to the page in JavaScript_javascript skills
The document.write command outputs text to the page
This example uses JavaScript’s document.write command to output the specified text to the page. The code is as follows:
Tips
If you use IE browser and it prompts: "To help protect security, Internet Explorer has restricted this webpage from running scripts or ActiveX spaces that can access your computer." Then please select "Allow blocked content" to allow IE browsing The server runs the above JavaScript code.
document.write outputs text with html tags to the page
If the text output to the page has an html tag, you only need to include the tag in the output text:
Explanation of syntax with examples
Similar to the previous "JavaScript Pop-up Prompt Box Example", document.write is a standard JavaScript syntax command used to output a specified string to a Web page. The characters to be output are enclosed in "" or '' and placed into document.write().
The document.write command and pop-up box command alert used in this example will be frequently used in future JavaScript learning, so be sure to use them skillfully.