[JavaScript HTML DOM]使用document物件,使用方法document.open()及close()
說明:
document.open() 開始一個HTML文檔
document.close() 關閉一個HTML文檔
用法
document.open(MIMEtype,replace)
MIMEtype
Optional. The type of document you are writing to. Default value is "text/html"
replace
Optional. If set, the history entry for the new document inherits
the history entry from the document which opened this document
此範例設計說明:
第一步、使用open,開一個新的HTML文檔
第二步、使用write,寫入資料
第三步、使用close,關閉
程式:
<html>
<head>
<title>[JavaScript-HTML_DOM]使用document物件,使用方法document.open()及close()</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function create() {
var newHtml = document.open("text/html", "replace");
newHtml.write("<html><body>[JavaScript-HTML_DOM]使用document物件,使用方法document.open()</body></html>");
newHtml.close();
}
</script>
</head>
<body>
<div>
<input type="button" value="新增一個 html網頁" onclick="create()">
</div>
</body>
</html>
圖:
- 首頁
- JAVA 目錄
- JAVA WEB 目錄
- JAVA 其他未分類 目錄
- Grails目錄
- jQuery 目錄
- Apache 目錄
- JavaScript 目錄
- Spring + Hibernate 目錄
- Hibernate 目錄
- Linux 目錄
- 程式開發工具目錄
- MySQL 目錄
- PHP目錄
- C/C++ 目錄
- Google App Engine 目錄
- HTML5/CSS3
- 程式開發基本資訊
- Android
- Oracle 目錄
- Struts 目錄