JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

Tips: How to Get the Currently Selected HTML Content in Major Browsers

发布时间 2023-06-29 17:20:46作者: y1j2x34
function getSelectionHtml() {
    const sel = window.getSelection();
    if (sel.rangeCount) {
        var container = document.createElement("div");
        for (var i = 0, len = sel.rangeCount; i < len; ++i) {
            container.appendChild(sel.getRangeAt(i).cloneContents());
        }
        return container.innerHTML;
    }
    return ''; 
}

Capatibility:

https://caniuse.com/selection-api

    本栏目推荐文章
  • 基于融合语义信息改进的内容推荐算法。Improved content recommendation algorithm integrating semantic information.
  • SpringMVC中如何设置响应的Content-Type(源码分析)
  • 从content-type设置看Spring MVC处理header的一个坑
  • request content was evicted from inspector cache
  • HTTP协议安全头部X-Content-Type-Options引入的问题
  • Content-Type常见类型
  • 前端发送请求的时候 Content-Type 内容分类, django后端分别怎么接收
  • PyQt报错:Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running
  • Java登陆第二十七天——多种方法Servlet映射、Content-Type
  • .NETCore Nuget 发布包含静态文件 content file
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们