Two commonly used client-side output methods in JavaScript
Two commonly used client output methods
document.write(str)
Description: In the <body> tag of the web page, output the content of str.
Document means "document", which is the entire web page.
Document is a document object that represents the entire web page.
write() is an output method of the document object.
"." Decimal point: Call the object's method through the decimal point (.).
str: ??Indicates the content to be output.
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> //在<body>中輸出一句話 document.write("歡迎來到php.cn"); </script> </head> <body> </body> </html>
##window.alert(str)
- Description: Pops up a warning dialog box in the current window, str is the content displayed in the dialog box.
- window represents the current browser window, and window is a window object.
- alert() method: Pops up a dialog box.
- str: ??Indicates the content to be output.
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> //打開網(wǎng)頁時(shí),彈出一個(gè)對話框 window.alert("歡迎來到php.cn"); </script> </head> <body> </body> </html>