js获取页面选择的文本内容

  getSelectedText() {
    if (window.getSelection) {
      return window.getSelection().toString();
    } else if (document.selection) {
      return document.selection.createRange().text;
    }
    return ''
  }
原文地址:https://www.cnblogs.com/xutongbao/p/11915724.html