ttxxyy112233
V2EX  ›  Android

安卓 WebView 中如何获取用户当前选中的字符串

  •  
  •   ttxxyy112233 · Mar 22, 2018 · 13286 views
    This topic created in 2979 days ago, the information mentioned may be changed or developed.

    用了 window.getSelection().toString()还是不行,不知道是什么情况

    3 replies    2018-03-23 10:22:47 +08:00
    crystom
        1
    crystom  
       Mar 22, 2018
    浏览器不支持,很正常
    ttxxyy112233
        2
    ttxxyy112233  
    OP
       Mar 22, 2018 via Android
    @crystom 原来是浏览器的问题吗 😂
    lukunlin
        3
    lukunlin  
       Mar 23, 2018
    前端问题的话就没必要来 V2 了吧,百度不是一大堆吗~



    一般使用 input 的 DOM 对象去调用 select 方法后,使用 document.execCommand("Copy")就可以把选中的内容复制到剪贴板了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2960 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 13:43 · PVG 21:43 · LAX 06:43 · JFK 09:43
    ♥ Do have faith in what you're doing.