?? 12-4 “execcommand”方法應用示例.htm
字號:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=GB2312" />
<title>12-4 “execCommand”方法應用示例</title>
<script>
//全選頁面內容
function selectAll(){
document.execCommand("SelectAll", false);
}
//彈出“另存為”對話框
function saveAs(){
document.execCommand("SaveAs", true, "C:\\sample.htm");
}
//將頁面的文本內容設置為粗體
function boldAll(){
//首先全選頁面文本
document.execCommand("SelectAll", false);
//然后調用切換粗體的命令
document.execCommand("Bold", false);
//最后清除選擇,恢復頁面的狀態
document.execCommand("Unselect", false);
}
//彈出“打印”對話框
function print(){
document.execCommand("Print");
}
</script>
</head>
<body style="overflow:auto; padding:0px; margin:0px;">
<div style="font-size:14px; color:white; font-family:Arial, 宋體; background-color:#6090DA; padding:4px 10px;">
你好
<script>
dt = new Date();document.write(",當前時間是 ");document.write(dt.toLocaleTimeString());
</script>
<br/><br/>
<input type="button" value="全選" onclick="this.blur();selectAll();" />
<input type="button" value="保存" onclick="this.blur();saveAs();" />
<input type="button" value="全文加粗" onclick="this.blur();boldAll();" />
<input type="button" value="打印" onclick="this.blur();print();" />
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -