Home > Web Front-end > JS Tutorial > body text

JavaScript uses output statements to implement web page special effects code_javascript skills

WBOY
Release: 2016-05-16 15:46:36
Original
1353 people have browsed it

This article mainly talks about the three most commonly used output statements, including alert() pop-up warning box, printing input statement, and console output. Please see the specific method below, with pictures and very detailed comments.

Copy code The code is as follows:

alert() pops up an alert box
window.alert(‘Continue learning’); Complete writing method

The effect is as follows:

JavaScript uses output statements to implement web page special effects code_javascript skills

Because alert belongs to the method of window object, and window can be omitted

So, usually we write like this: alert(‘Welcome to learn’); // Pop up warning box

But, this, a dialog box will pop up every time, which will scare some timid people, hehe, just kidding, mainly because the user experience is not good. Therefore, use it as little as possible. It is generally used for testing

Document printout

There are two commonly used print input statements

Copy code The code is as follows:

document.write()
document.writeln()

Note: These two belong to document objects, and document cannot be omitted.

writeln is the abbreviation of write line and will generate a

at the end

Under normal circumstances, document.writeln() will generate a space at the end, and the difference between the two is usually not visible.

In the pre tag, there will be a line break. As follows:

JavaScript uses output statements to implement web page special effects code_javascript skills

The display effect is as follows:

JavaScript uses output statements to implement web page special effects code_javascript skills

Console output (console)

Copy code The code is as follows:

Console Console
Console.log() is most used for testing and needs to be deleted after writing.
Console.info() and console.log are exactly the same. The only difference is that there will be one in front of him!
Console.warn() The meaning of warning
Console.error() Error message
JavaScript uses output statements to implement web page special effects code_javascript skills

The effect is as follows:

JavaScript uses output statements to implement web page special effects code_javascript skills

The above is the entire content of this article, I hope you all like it.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!