Breaking News

【JavaScript】動態生成HTML頁面



<html>
<head>
<title>動態生成HTML頁面</title>
<script type="text/javascript">
function create() {
    var content = "<html><head><title>動態生成的HTML文檔</title></head>";
    content += "<body><font size='2'><b>這個文檔的內容是利用document對象動態生成的</b></font>";
    content += "</body></html>";
    
    var newWindow = window.open(); 
    newWindow.document.write(content);   
    newWindow.document.close();  
}
</script>
</head>
<body>
<form>
<input type="button" value="創建HTML文檔" onclick="create()">
</form>
</body>
</html>



沒有留言