document.write() 用法
在JavaScript中document.write()函數可以向文檔寫入HTML表達式或JavaScript代碼,用法“document.write(exp1,exp2,exp3,…)”,該函數可接受任何多個參數,並將其寫入文檔中。
document.write() 說明
雖然根據 DOM 標准,該方法只接受單個字符串作為參數。
我們通常按照兩種的方式使用 write() 方法:一是在使用該方在文檔中輸出 HTML,另一種是在調用該方法的的窗口之外的窗口、框架中產生新文檔。在第二種情況中,請務必使用 close() 方法來關閉文檔。
document.write() 實例
<html>
<body>
<script type="text/javascript">
document.write("Hello World!");
</script>
</body>
</html>
以上就是JavaScript document.write() 用法的詳細內容。