How to capture iOS Safari event on text selection change within Javascript?

后端 未结 2 825
花落未央
花落未央 2021-01-02 07:21

Following scenario: When selecting text on iOS Safari (lets assume a \"normal\" html page) an blue overlay occurs, indicating that you have selected a specific passage. Furt

相关标签:
2条回答
  • 2021-01-02 07:42

    Mobile Safari supports the selectionchange event, which fires on Document nodes:

    document.addEventListener("selectionchange", function() {
        alert("Selection changed!");
    }, false);
    
    0 讨论(0)
  • 2021-01-02 07:47

    I've found that this event fires multiple times even on a single word selection (with a tap), and of course it fires when you drag the selection handles ...

    I created a small workaround to get only the text selection end event.

    you can see it here: End of text selection event?

    or in a small post on my blog: http://www.dimshik.com/end-of-text-selection-event-on-ios-workaround/

    0 讨论(0)
提交回复
热议问题