【问题标题】:Input iframe stop work on IOS in second tap ionic v1输入 iframe 在第二次点击 ionic v1 中停止在 IOS 上工作
【发布时间】:2020-04-09 08:33:46
【问题描述】:

我有一个具有 iframe 的 ionic v1 应用程序。我尝试在输入字段中写入,没关系。但是当我再次点击输入时,我不能再写了。这仅在 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);
    }

【问题讨论】:

    标签: javascript ios ionic-framework iframe webview


    【解决方案1】:

    我通过在 iframe 所在的视图中不断保持焦点来解决问题

    if (typeof cordova !== 'undefined' && $cordovaDevice.getPlatform() === 'iOS') {
    window.setInterval(function() {
       var myFrame = document.getElementById('Iframe');
       myFrame.contentWindow.focus();
    }, 500);
    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-15
      • 1970-01-01
      相关资源
      最近更新 更多