12-5 “execcommand”方法应用示例.htm

来自「JAVASCRIPT完全自学手册,中源码的验证修订实例」· HTM 代码 · 共 33 行

HTM
33
字号
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=GB2312" />
<title>12-5  “execCommand”方法应用示例</title>
<style>
* { font-size:12px; font-family:宋体, Arial; } /*规定了所有的字体样式*/
body { overflow:auto; background-color:buttonface; border-style:none; }
a { margin:2px 10px; color:white; font-weight:bold; }
#d01 { font-size:14px; color:white; font-family:Arial, 宋体; background-color:#6090DA; padding:4px 10px; height:24px; }
</style>
<script>
function insertLink(){
    var newLink = document.createElement("a");
    newLink.innerHTML = $("txtDesc").value;
    newLink.href = $("txtAddr").value;
    $("d01").appendChild(newLink);
}
function $(str){ return(document.getElementById(str)); }
</script>
</head>
<body>
<table>
    <tr>
        <td>链接地址:</td><td><input id="txtAddr"></td>
    </tr><tr>
        <td>链接描述:</td><td><input id="txtDesc"></td>
    </tr><tr>
        <td cols="2"><input type="button" value="添加" onclick="insertLink();"></td>
    </tr>
</table>
<div id="d01" ></div>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?