Skip to content
Advertisement

getSelection not working properly in iOS 12

Functions document.getSelection() and window.getSelection() do not work in iOS 12.

The problem is reproduced in Safari, Google Chrome and WKWebView.

In iOS 11 and MacOS (any version), these functions are work.

Can you advise?

Example:

JavaScript

enter image description here

Advertisement

Answer

I don’t really know why document.getSelection() and window.getSelection() does not work in iOS 12, but the code bellow will return the offset within the node when the user clicks on it.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement