Home  >  Article  >  Web Front-end  >  JavaScript document.write() usage

JavaScript document.write() usage

Guanhui
GuanhuiOriginal
2020-06-19 14:06:594214browse

JavaScript document.write() usage

document.write() Usage

In JavaScript, the document.write() function can write HTML expressions or JavaScript code to the document , usage "document.write(exp1,exp2,exp3,....)", this function can accept any multiple parameters and write them into the document.

Recommended video tutorial: "JavaScript"

document.write() Description

Although according to the DOM standard, this method only accepts a single string as parameter.

We usually use the write() method in two ways: one is to use this method to output HTML in the document, and the other is to generate it in a window or frame other than the window in which the method is called. New document. In the second case, be sure to use the close() method to close the document.

document.write() Example

<html>
<body>
<script type="text/javascript">
document.write("Hello World!");
</script>
</body>
</html>

Recommended tutorial: "JS Tutorial"

The above is the detailed content of JavaScript document.write() usage. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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