window.open然后关闭会导致输入不可点击

时间:2019-06-09 15:35:56

标签: jquery html input printing clickable

我有一个方法可以将内容写入另一个选项卡并将其打印出来,一旦该选项卡关闭,它将返回我的主应用程序。但是它返回了,看来我所有的输入都不再可单击了。这意味着我无法在任何输入元素中获得光标。如果我在屏幕外单击并返回,则所有操作将重新开始。

这是我的方法:

this.printForm = function (html) {
        //check for content otherwise repeat
        var checkForContent = function () {
            setTimeout(function() {
                var tmp = WinPrint.document.querySelector('body').innerHTML;

                if (tmp.length) {
                    WinPrint.document.close();
                    WinPrint.focus();
                    WinPrint.print();
                    WinPrint.close();

                } else {
                    checkForContent();
                }
            }, 200);
        }

        var WinPrint = window.open();

        if (WinPrint === null) {
            swal({
                title: $translate.instant("ALLOW_POP_UP"),
                text: $translate.instant("IN_ORDER_FOR_ALL_FEATURES_TO_WORK_PLEASE_ALLOW_POP_UPS_FOR_THIS_APPLICATION"),
                type: "warning"
            });
        } else {
            WinPrint.document.write(html);

            checkForContent();
        }
    }

我发现的唯一解决方法是,如果我在WinPrint.close()之后放了一条警报消息,则由于某种原因而将其修复。但是我当然不希望弹出窗口,因为它很丑

0 个答案:

没有答案