我有一个 ionic v1 应用程序,它有一个 iframe
。我尝试在输入字段中写入,但没问题。但是当我第二次点击输入时,我就无法再写了。这种情况只发生在IOS;对于 Android 上任何具有输入字段的 iframe
来说,它都能完美运行。
我尝试通过window.addEventListener
处理焦点和触摸事件,但它仍然不起作用。我还尝试向上和向下触发键盘。我已经有好几个星期的时间来处理这件事了,如果你能帮助我,我将非常感激。在这个链接中我留下了一些证据Video Evidence
window.addEventListener('blur', function() {
focusElement();
});
window.addEventListener('native.keyboardshow', focusElement);
function focusElement() {
$timeout(function() {
var iframe = document.getElementById('ofertasExclusivasIframe');
iframe.contentWindow.focus();
console.log("----------loaded---------", iframe)
}, 250);
}
$scope.$on('$destroy', handleDestroy);
function handleDestroy() {
$window.removeEventListener('native.keyboardshow', focusElement);
}
最佳答案
我通过在 iframe 所在的 View 中不断保持焦点来解决这个问题
if (typeof cordova !== 'undefined' && $cordovaDevice.getPlatform() === 'iOS') {
window.setInterval(function() {
var myFrame = document.getElementById('Iframe');
myFrame.contentWindow.focus();
}, 500);
}
关于javascript - 输入 iframe 在第二次点击 ionic v1 中停止在 IOS 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59364082/