例如
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>覆蓋文檔</title> </head> <body> <script> document.write("首先輸出"); </script> <p>請點擊這</p> <br/> <input type="button" onclick="test()" value="調用函數"/> <script> function test(){ document.write("覆蓋輸出:"); document.write(Date()); } </script> </body> </html>