本文介绍了谷歌浏览器块时打印preVIEW打开的子窗口Ajax请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有2个文件: index.html的 print.html

首先一个包括打开 print.html 使用简单的命令按钮:

First one contains a button that opens print.html using simple command:

window.open("print.html", "_blank", "menubar=yes,toolbar=yes,status,scrollbars,resizable");

print.html 只包含一个按钮,打开打印preVIEW对话框:

print.html contains only one button that opens print preview dialog:

<button onclick="window.print();">

打开打印preVIEW对话框时出现问题。在这种情况下,对 index.html的任何行动 - 即的的文件,该文件启动Ajax请求 - 是暂时的封锁,进入队列。只有当preVIEW关闭浏览器触发的所有请求。

The problem appears when print preview dialog is opened. In this case any action on index.html - i.e. the other file that initiate ajax request - is temporary blocked and put into queue. And only when preview is closed browser fires all requests.

我可以看到它只有在谷歌浏览器(24.0.1312.52米)。

I can see it only in Google Chrome (24.0.1312.52 m).

任何人都可以证实,这是Chrome的错误?

Can anybody confirm that this is Chrome's bug?

推荐答案

有一个Chrome浏览器的bug,其中 window.print()不工作时,有一个标记DOM的。它可以通过调用这个函数来解决:

there is a Chrome bug where window.print() does not work when there is a tag in the DOM. It might be solved by calling this function:

function printPage() {
    window.print();

    //workaround for Chrome bug - https://code.google.com/p/chromium/issues/detail?id=141633
    if (window.stop) {
        location.reload(); //triggering unload (e.g. reloading the page) makes the print dialog appear
        window.stop(); //immediately stop reloading
    }
    return false;
}

这篇关于谷歌浏览器块时打印preVIEW打开的子窗口Ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 17:49