小白教程
所有教程
关于
Search
172.71.254.32
172.71.254.32
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Met doc write”的源代码
本页内容
上一节:
Prop_doc_url
下一节:
Met_doc_writeln
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:document.write()}}[[Category:dom obj document|44]] = HTML DOM write() 方法 = [[dom obj document|Document 对象]] == 定义和用法 == write() 方法可向文档写入 HTML 表达式或 JavaScript 代码。 == 语法 == <pre> document.write(exp1,exp2,exp3,...)</pre> {| class="table table-striped table-hover" ! 参数 ! 描述 |- | exp1,exp2,exp3,... | 可选。要写入的输出流。多个参数可以列出,他们将按出现的顺序被追加到文档中 |} == 浏览器支持 == 所有主要浏览器都支持 write() 方法 == 实例 1 == 向输出流写入一些文本: <sample title="" desc="" lang="html" hererun="1"> <html> <body> <script> document.write("Hello World!"); </script> </body> </html> </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <script> document.write("Hello World!"); </script> </body> </html> </run> == 实例 2 == 向输出流写入一些格式文本: <sample title="" desc="" lang="html" hererun="1"> <html> <body> <script> document.write("<h1>Hello World!</h1><p>Have a nice day!</p>"); </script> </body> </html> </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <script> document.write("<h1>Hello World!</h1><p>Have a nice day!</p>"); </script> </body> </html> </run> == 实例 3 == write() 与 writeln() 的区别: <sample title="" desc="" lang="html" hererun="1"> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <p>注意write()方法不会在每个语句后面新增一行:</p> <script> document.write("Hello World!"); document.write("Have a nice day!"); </script> <p>注意writeln()方法在每个语句后面新增一行:</p> <script> document.writeln("Hello World!"); document.writeln("Have a nice day!"); </script> </body> </html> </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <p>注意write()方法不会在每个语句后面新增一行:</p> <pre> <script> document.write("Hello World!"); document.write("Have a nice day!"); </script> </pre> <p>注意writeln()方法在每个语句后面新增一行:</p> <pre> <script> document.writeln("Hello World!"); document.writeln("Have a nice day!"); </script> </pre> </body> </html> </run> [[dom obj document|Document 对象]]
返回至“
Met doc write
”。
上一节:
Prop_doc_url
下一节:
Met_doc_writeln