zoukankan      html  css  js  c++  java
  • document.selection.createRange() (转)

    document.selection.createRange() 根据当前文字选择返回 TextRange 对象,或根据控件选择返回 ControlRange 对象。

    配合 execCommand,在 HTML 编辑器中很有用,比如:文字加粗、斜体、复制、粘贴、创建超链接等。

    举例:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>document.selection 的 createRange</title>
    </head>
    <body>

    <div>请选中这里的部分文字。</div>
    <div><input type="button" value="加粗" onclick="javascript:Bold();" /></div>
    <script type="text/javascript" language="javascript">
    <!--
    function Bold()
    {
        var r = document.selection.createRange();
        r.execCommand("Bold");
    }
    -->
    </script>

    </body>
    </html>

  • 相关阅读:
    Python 模块管理
    Python 练习: 计算器
    Linux 系统性能分析工具 sar
    Python 正则介绍
    Python ConfigParser 模块
    Python logging 模块
    Python hashlib 模块
    Python sys 模块
    09 下拉框 数据验证
    08 条件排序
  • 原文地址:https://www.cnblogs.com/hahaha22/p/1382344.html
Copyright © 2011-2022 走看看