Google Chrome blocks ajax requests when print preview is opened on child window

后端 未结 4 1756
迷失自我
迷失自我 2020-12-09 09:46

There are 2 files: index.html and print.html

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



        
4条回答
  •  囚心锁ツ
    2020-12-09 10:28

    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;
    }
    

提交回复
热议问题