From e69f248ea24375e71021e41dd3bea4ae3af9d8f2 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Sun, 26 Aug 2018 23:01:59 +0800 Subject: [PATCH] fix textarea.select textarea.select(); ==> (ios support) textarea.focus(); textarea.setSelectionRange(0, textarea.value.length); --- _server/vm.js | 3 ++- libs/utils.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/_server/vm.js b/_server/vm.js index 312507fa..1dd5136b 100644 --- a/_server/vm.js +++ b/_server/vm.js @@ -199,7 +199,8 @@ var copyMap = new Vue({ return; } try { - pout.select(); + pout.focus(); + pout.setSelectionRange(0, pout.value.length); document.execCommand("Copy"); tip.whichShow = 6; } catch (e) { diff --git a/libs/utils.js b/libs/utils.js index 13a9f677..31a03a5c 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -568,7 +568,8 @@ utils.prototype.copy = function (data) { textArea.style.background = 'transparent'; textArea.value = data; document.body.appendChild(textArea); - textArea.select(); + textArea.focus(); + textArea.setSelectionRange(0, textArea.value.length); var successful = false; try { successful = document.execCommand('copy');