I have a small web page, which uses the following code to set a selection by one click:
function select_element()
{
if (window.getSelection && document.createRange) {
sel = window.getSelection();
range = document.createRange();
range.selectNodeContents(this);
sel.removeAllRanges();
sel.addRange(range);
} else
if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(this);
range.select();
}
}
It works in most browsers as you can see here.
But it does not work on an iPhone. The text just flashes and nothing gets selected. How to select text on the iPhone browser with JavaScript?
The aim is to make it easy to copy the text to the clipboard.
Aucun commentaire:
Enregistrer un commentaire