JavaScript document write String content writes nothing o

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

The following html will output nothing on html page, you may meet it before.

<html><head>    <title>Tmp HTML</title>    <script type="text/javascript">        document.write(String.fromCharCode(0x204A));    </script></head><body></body></html>

Why nothing displayed? It is because bothdocument.write and document.writeln method output text into anunready (open) document. That is to say, when the page finishes loading, the document becomesclosed. An attempt to document.write in it will cause the contents to be erased.

You can work around as following:

<html><head>    <title>Tmp HTML</title>    <script type="text/javascript">        function MyDocumentWrite() {            document.write(String.fromCharCode(0x204A));        }        window.onload = MyDocumentWrite;    </script></head><body></body></html>
           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

这里写图片描述

猜你喜欢

转载自blog.csdn.net/yffhhffv/article/details/83820385