1 function getSelectedText() {
 2   if (window.getSelection) {
 3     // This technique is the most likely to be standardized.
 4     // getSelection() returns a Selection object, which we do not document.
 5     return window.getSelection().toString();
 6   }else if (document.getSelection) {
 7     // This is an older, simpler technique that returns a string
 8     return document.getSelection();
 9   }else if (document.selection) {
10     // This is the IE-specific technique.
11     // We do not document the IE selection property or TextRange objects.
12     return document.selection.createRange().text;
13   }
14 }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2022-01-27
  • 2022-12-23
  • 2022-03-05
猜你喜欢
  • 2022-12-23
  • 2021-05-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案