iOS 12.2上的编程JavaScript复制问题
我有一个Phonegap应用程序,可以点击一个按钮,将一些文本添加到你的剪贴板。在我将手机升级到iOS 12.2之前,这一直在工作 我在iOS 12.2的其他iPhone上进行了测试,问题也在那里。在12.2版本的模拟器中,它似乎正在工作,所以我不太确定问题出在哪里 我在这里添加了代码,以便您可以看到它是如何工作的 有人知道怎么了吗 剪贴板=(函数(窗口、文档、导航器){ var textArea, 抄袭iOS 12.2上的编程JavaScript复制问题,javascript,ios,safari,Javascript,Ios,Safari,我有一个Phonegap应用程序,可以点击一个按钮,将一些文本添加到你的剪贴板。在我将手机升级到iOS 12.2之前,这一直在工作 我在iOS 12.2的其他iPhone上进行了测试,问题也在那里。在12.2版本的模拟器中,它似乎正在工作,所以我不太确定问题出在哪里 我在这里添加了代码,以便您可以看到它是如何工作的 有人知道怎么了吗 剪贴板=(函数(窗口、文档、导航器){ var textArea, 抄袭 function isOS() { return navigator.userAg
function isOS() {
return navigator.userAgent.match(/ipad|iphone/i);
}
function createTextArea(text) {
textArea = document.createElement('textArea');
textArea.readOnly = true;
textArea.value = text;
document.body.appendChild(textArea);
}
function selectText() {
var range,
selection;
if (isOS()) {
range = document.createRange();
range.selectNodeContents(textArea);
selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
textArea.setSelectionRange(0, 999999);
} else {
textArea.select();
}
}
function copyToClipboard() {
document.execCommand('copy');
document.body.removeChild(textArea);
}
copy = function(text) {
createTextArea(text);
selectText();
copyToClipboard();
};
return {
copy: copy
};
})(窗口、文档、导航器) 我也面临同样的问题。如果您解决了问题,请与他人分享您的解决方案。