https://stackoverflow.com/questions/2920150/insert-text-at-cursor-in-a-content-editable-div

function insertTextAtCaret(text) {
var sel, range;
if (window.getSelection) {
sel = window.getSelection();
if (sel.getRangeAt && sel.rangeCount) {
range = sel.getRangeAt(0);
range.deleteContents();
range.insertNode( document.createTextNode(text) );
}
} else if (document.selection && document.selection.createRange) {
document.selection.createRange().text = text;
}
}

insert-text-at-cursor-in-a-content-editable-div的更多相关文章

  1. Jquery的text()和html()方法在li与div取值结果解析

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. HTML5 Content Editable实践

    基于此开发文档:https://developer.mozilla.org/zh-CN/docs/Web/Guide/HTML/Content_Editable 问题:通过contenteditabl ...

  3. font 和 text ,cursor

    font:14px/30px/"宋体"这种写法等于 font-size="14px" line-heigiht="30px" font-fa ...

  4. 指令-arContentedit-可编辑的高度自适应的div

    <div  ar-contentedit="true" contenteditable="true"  contenteditable="pla ...

  5. [Linux-vi] The simple set of vi command

    Source : https://www.cs.colostate.edu/helpdocs/vi.html What is vi? The default editor that comes wit ...

  6. AnjularJs的增删改查(单页网站)

    2016.6.4 学习文献: 你的第一个AngularJS应用:https://segmentfault.com/a/1190000000347412 AngularJS 提交表单的方式:http:/ ...

  7. Python爬虫使用lxml模块爬取豆瓣读书排行榜并分析

    上次使用了BeautifulSoup库爬取电影排行榜,爬取相对来说有点麻烦,爬取的速度也较慢.本次使用的lxml库,我个人是最喜欢的,爬取的语法很简单,爬取速度也快. 本次爬取的豆瓣书籍排行榜的首页地 ...

  8. Insert Plain Text and Images into RichTextBox at Runtime

    Insert Plain Text and Images into RichTextBox at Runtime' https://www.codeproject.com/Articles/4544/ ...

  9. requests的content与text导致lxml的解析问题

    title: requests的content与text导致lxml的解析问题 date: 2015-04-29 22:49:31 categories: 经验 tags: [Python,lxml, ...

  10. requests中text,content,json之间的区别

    response.text : 返回一个字符串\n",content : 返回二进制\n",json() : 返回对象"

随机推荐

  1. VUE2.0 脚手架搭建项目,如何配置本地IP地址访问项目,详解

    1.首先找到config文件夹目录下的 index.js文件 // Various Dev Server settings //host: 'localhost' //将localhost进行替换成 ...

  2. Oracle 数据库升级过程中的主要步骤

    Oracle 数据库升级包括六个主要步骤. Oracle 数据库的升级步骤工作流 步骤 1:准备升级 Oracle 数据库 熟悉 Oracle 数据库新版本的特性. 确定新版本的升级路径. 选择升级方 ...

  3. postman导出Collection文件

    postman接口调用工具可以将曾经使用过的请求配置导出为文件保存,方法如下: 1.编写一个接口测试用例 2.按组分类 3.导出 参考来源: https://blog.csdn.net/IBLiplu ...

  4. 1.2 Git&Github

    Git&GitHub 一.必做部分 1.Git的安装与命令学习 下载&安装 PC端科学经费不足所以Github下载一直失败,最后去官网https://gitforwindows.org ...

  5. 训练题——DS18B20部分

    Author:Cherry_Ywj 0. 前言 本文档以 DS18B20 为例,主要介绍如何针对一种传感器编写相应的驱动库,驱动是单片机开发中难度较大的一环.从看别人代码并对照 datasheet 开 ...

  6. Ubuntu ROOT默认密码设置

    Ubuntu默认密码设置 Ubuntu默认是不设置ROOT密码的,如果需要安装一些包则需要从普通用户调转至ROOT用户,这个时候就需要设置一下密码了. 下面这种情况 chen@chen:~/Deskt ...

  7. CORS预检

    CORS是一种常见的跨域机制,一般由服务端提供一个Access-Control-Allow-Origin头来解决问题,但是这仅对一些"简单请求"有效.那么何谓"简单请求& ...

  8. div 自动滚轮2

    HTML: <div class="cal_bottom" style="height:78%;margin-top:2%;overflow:auto;" ...

  9. Vuex----Getters

    Getter 用于对 Store中的数据进行加工处理形成新的数据. Getter 不会修改 Store 中的原数据,它只起到一个包装器的作用,将Store中的数据加工后输出出来. const stor ...

  10. Linux系统管理实战-软件包管理

    软件包管理 在Linux中,不同的发行版软件管理的方式可能不一样,具体来说,主要分为两大派: RPM: Rpm Package Manager CentOS系统软件安装三种方式 rpm:安装简单,可定 ...