javascript - 输入 iframe 在第二次点击 ionic v1 中停止在 IOS 上工作

标签 javascript ios ionic-framework iframe webview

我有一个 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/

相关文章:

javascript - 创建一个倒计时器哪个是最好的解决方案?

javascript - 单击 Button 不会向下钻取 Table Bootstrap 4 和 JS 和 JQuery 中的元素

javascript - React 中使用 FileReader 的正确获取主体是什么

ios - 键值编码获取列表中的元素

javascript - React 惯用的方式来更新状态中的 Map 对象

ios - UICollectionView 与自定义 UICollectionViewLayout validateLayoutInRect accertion

ios - AVFoundation 以 MP4 格式录制视频

javascript - 使用 Ionic 和 AngularJS 在 $scope 中更改变量值时, View 中的变量值未更新

php - 插入选定的数据作为外键和 SQLSTATE[23000] : Integrity constraint violation: 1048

java - ionic 无法构建android