惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recorded Future
Recorded Future
Security Archives - TechRepublic
Security Archives - TechRepublic
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Jina AI
Jina AI
I
InfoQ
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
腾讯CDC
GbyAI
GbyAI
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Azure Blog
Microsoft Azure Blog
F
Fortinet All Blogs
博客园 - 聂微东
美团技术团队
The Register - Security
The Register - Security
Engineering at Meta
Engineering at Meta
Apple Machine Learning Research
Apple Machine Learning Research
雷峰网
雷峰网
S
Schneier on Security
量子位
A
About on SuperTechFans
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
S
SegmentFault 最新的问题
Know Your Adversary
Know Your Adversary
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
Simon Willison's Weblog
Simon Willison's Weblog
PCI Perspectives
PCI Perspectives
B
Blog
K
Kaspersky official blog
V
Vulnerabilities – Threatpost
aimingoo的专栏
aimingoo的专栏
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
G
Google Developers Blog
L
LINUX DO - 最新话题
Forbes - Security
Forbes - Security
AWS News Blog
AWS News Blog
P
Palo Alto Networks Blog
Security Latest
Security Latest
爱范儿
爱范儿
Attack and Defense Labs
Attack and Defense Labs
IT之家
IT之家
L
LINUX DO - 热门话题
D
Docker
P
Proofpoint News Feed
Y
Y Combinator Blog
P
Proofpoint News Feed

博客园 - 杞人

float、double为0判断 Excel操作知识(持续补充) 算法设计方案 C# 动态编译及反射执行 解决由于DTD规范引发Table设置高度无效 - 杞人 - 博客园 VS.NET 代码折叠Region C#访问FTP VS.NET 自动生成版本号问题 - 杞人 - 博客园 UDP通讯 DataSet中表的关系及约束 Web Services 获取当前路径! Windows Services .NET超时解决方案 Facade 外观模式(结构型模式) Decorator 装饰模式(结构型模式) AJAX.NET请求时发生异常处理方案 setTimeout和setInterval的使用说明 Composite 组合模式(结构型模式)
write( ) 和 writeln( )使用说明
杞人 · 2007-06-18 · via 博客园 - 杞人

1、Microsoft JScript 提供了两种方式来在浏览器中直接显示数据。可以使用 write( ) 和 writeln( ),这两个函数是document 对象的方法。

2、writeln( ) 方法与 write( ) 方法几乎一样,差别仅在于是前者将在所提供的任何字符串后添加一个换行符。在 HTML 中,这通常只会在后面产生一个空格;不过如果使用了 <PRE> 和 <XMP> 标识,这个换行符会被解释,且在浏览器中显示。

3、在调用 write( ) 方法时,如果该文档不处于在调用 write( ) 方法时的打开和分析的过程中,该方法将打开并清除该文档,所以它可能是有危险的。

示例:

<html>
 <head>
   <script>
  function DocWrite()
  {
   //<PRE>体现出2的问题
   document.write("<h1>这是使用document.write输出的</h1>");
   document.writeln("<h1>这是使用<PRE>document.writeln输出的</PRE></h1>");
  }
   </script>
 </head>
 <body>
<!--两处调用DocWrite()体现出3的问题-->
  <script>
   DocWrite();
  </script>
  <p>正文内容</p>
  </p><input type="button" name="Submit" value="按钮" onclick="DocWrite()"></p>
 </body>
</html>