zoukankan      html  css  js  c++  java
  • javascript学习笔记1-document.write

     1 <html xmlns="http://www.w3.org/1999/xhtml">
     2 <head>
     3     <title></title>
     4     <script type="text/javascript">
     5         function ShowMessage() {
     6             document.write("You are using JavaScript!");
     7         }
     8     </script>
     9 </head>
    10 <body onload="ShowMessage()">
    11     <h1>
    12         A first JavaScript example</h1>
    13 </body>
    14 </html>
    View Code

    结果:标签<h1>A first JavaScript example</h1>里的内容不见了

    原因:ShowMessage函数在页面主题载入后才调用,此时浏览器认为文档(document)已经关闭,所以IE浏览器会将文档重新打开,原来的文本即<h1>A first JavaScript example</h1>被清除了,此时只能看到ShowMessage显示的You are using JavaScript!消息了

    注:在360安全浏览器上也是同样效果

  • 相关阅读:
    Html
    git和github简易教程
    Java基础
    如何学习一门语言
    leetcode题解(持续更新)
    浅谈安全威胁+引子
    内网渗透基础
    Java运算符
    Java修饰符
    Java变量类型
  • 原文地址:https://www.cnblogs.com/zhyue93/p/JavaScript1.html
Copyright © 2011-2022 走看看