最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Page not reloading after print the window with Jquery - Stack Overflow

programmeradmin3浏览0评论

Hey I don't know why my page is not reloading without cache after using window.print() . the window is reloading when i am typing window.location.reload(true) on browser console but not working after printing . I've try but can't figure-out why this is not working here.

$('#print_report').click(function(){
      $('body').html($('#cashReport').html());
      window.print();
      return window.location.reload(true);
});

Hey I don't know why my page is not reloading without cache after using window.print() . the window is reloading when i am typing window.location.reload(true) on browser console but not working after printing . I've try but can't figure-out why this is not working here.

$('#print_report').click(function(){
      $('body').html($('#cashReport').html());
      window.print();
      return window.location.reload(true);
});
Share Improve this question asked Aug 28, 2015 at 22:05 RanaRana 1882 silver badges15 bronze badges 2
  • Try without "return". Just - window.location.reload(); – WebArtisan Commented Aug 28, 2015 at 22:10
  • I've tried @Alicelf but not work. – Rana Commented Aug 28, 2015 at 22:16
Add a ment  | 

5 Answers 5

Reset to default 5

You can reload the page after the print process finishes.You can listen for the after print event using window.onafterprint

$('#print_report').click(function(){
      $('body').html($('#cashReport').html());
      window.print();
});

 window.onafterprint = function(){
      window.location.reload(true);
 }

It might be too late but I got to this issue and none of the solutions worked when using Print to PDF and some real printers also, I found the solution using:

           setInterval(function(){
              window.location.reload(true);
           }, 200);
           window.print();

Consider the afterprint event. See https://developer.mozilla/en-US/docs/Web/API/WindowEventHandlers/onafterprint

window.location.href = window.location.href  ;

you can use this javascript function and call it after print

   <script>
    function refreshParent() {
        window.opener.location.reload(true);
    }
   </script>
发布评论

评论列表(0)

  1. 暂无评论