博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
兼容的获取选择文本方法
阅读量:4579 次
发布时间:2019-06-09

本文共 402 字,大约阅读时间需要 1 分钟。

if(document.selection){    //IE    var selectRange = document.selection.createRange();    if(selectRange.text.length > 0){        word = selectRange.text;    }}else if(window.getSelection){    //FF 标准浏览器    word = window.getSelection().toString();}else if(document.getSelection){    //一个比较老的方法    word = document.getSelection();}

文章来源:

转载于:https://www.cnblogs.com/gafish/archive/2011/12/29/2305575.html

你可能感兴趣的文章