How to Direct an Output to Console in JavaScript
The "document.write" function lets you write text from your scripts directly to the console. The text displays in the user's browser window. You can link the function to a button or link in your HTML code or write text to the browser console as soon as the page loads. You can also write HTML code using the document.write function.
Instructions
-
-
1
Right-click the HTML file that you want to use to print text to the browser console. Click "Open With," then choose your JavaScript or HTML editor.
-
2
Create a "script" block, which is where all of your JavaScript code is placed. Add the following tags within the head tags:
<script type="text/javascript"> </script>
-
-
3
Add the "document.write" function to output a message to the browser. For instance, the following code displays "Hello World" to the user:
document.write("Hello World");
-
1