【问题标题】:Retrieve selected text in IE [duplicate]在 IE 中检索选定的文本 [重复]
【发布时间】:2012-10-01 12:55:11
【问题描述】:

可能重复:
getSelection() not working in IE

我试图获取选定的内容,结果发现:

   window.getSelection().toString();

它适用于大多数浏览器,除了显而易见的 IE。

那么,该怎么办?

【问题讨论】:

标签: javascript internet-explorer selection getselection


【解决方案1】:

只有 IE9 及以上版本支持window.getSelection()。您可以在早期版本中改用document.selection

【讨论】:

    【解决方案2】:

    完整的语法是:

    document.selection.createRange().text;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-19
      • 1970-01-01
      • 1970-01-01
      • 2016-09-17
      • 2012-06-28
      • 1970-01-01
      • 1970-01-01
      • 2017-06-26
      相关资源
      最近更新 更多