Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the differences between writeln and write in javascript

Shulou Source: shulou.com Published: 2022-06-02 07:22:59 09月11日 Update

This article mainly introduces what is the difference between writeln and write in javascript. It is very detailed and has certain reference value. Friends who are interested must read it!

The difference between writeln and write in javascript: when the writeln () method outputs data in the browser, it adds a newline character to the end of the data, while the write () method does not add a newline character to the end of the data in the browser, so it cannot wrap.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

Javascript provides two ways to display data directly in a browser. You can use write () and writeln (), which are methods of the document object.

The writeln () method is almost the same as the write () method, except that Write cannot wrap, and Writeln can wrap.

Writeln () will add a newline character after any string provided. The write () method does not add a newline character to the end of the string.

Note: the line wrapping effect of writeln can not be seen in the web page, it is displayed by the browser as a space.

You can't see the effect in both the HTML file and the source file of JSP. Readers can add pre-formatted tags to the tags to view the effect.

[xss_clean] ("write"); [xss_clean] ln ("writln"); [xss_clean] ("write")

You can also use the open method to open a new window to view the test

With (window.open ()) {[xss_clean] ("write") [xss_clean] ln ("writeln") [xss_clean] ln ("write")}

Then you can see the effect by viewing the web page source file in the pop-up window.

The above is all the content of the article "what is the difference between writeln and write in javascript". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Method data browser browse newline character effect end content character string label source file article web page output two value interest function enough Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information OPPO Reno Shulou Technology macOS Docker