I have modal dialog, with some text that should be printed, and print link. So when I press print, it takes me about 30 sec to open preview dialog in chrome(firefox, safari, ie are fine). What is the reason of that?
dialog:
<div id="dialog">
<div id="to_print_data">
My data to print!!!!!
</div>
Click <a href="#" onclick="window.print(); return false;"> here</a>
</div>
<style>
@media print {
body * {
visibility:hidden;
}
#to_print_data, #to_print_data * {
visibility:visible;
}
#to_print_data {
position:absolute;
left:0!important;
top:0!important;
border:0!important;
font-size:16px!important;
}
}
</style>
UPDATE:
I found cause, in the background running some script, that makes post request, and request have pending status about 30 sec, after it finished print-dialogue appears. How to prevent this behavior, when print waiting for post request to finish, without removing script?
I have modal dialog, with some text that should be printed, and print link. So when I press print, it takes me about 30 sec to open preview dialog in chrome(firefox, safari, ie are fine). What is the reason of that?
dialog:
<div id="dialog">
<div id="to_print_data">
My data to print!!!!!
</div>
Click <a href="#" onclick="window.print(); return false;"> here</a>
</div>
<style>
@media print {
body * {
visibility:hidden;
}
#to_print_data, #to_print_data * {
visibility:visible;
}
#to_print_data {
position:absolute;
left:0!important;
top:0!important;
border:0!important;
font-size:16px!important;
}
}
</style>
UPDATE:
I found cause, in the background running some script, that makes post request, and request have pending status about 30 sec, after it finished print-dialogue appears. How to prevent this behavior, when print waiting for post request to finish, without removing script?
Share Improve this question edited Mar 20, 2013 at 15:38 Sergey asked Mar 19, 2013 at 13:09 SergeySergey 9632 gold badges20 silver badges50 bronze badges 13- 1 Could be specific to your particular instance of Chrome (too many extensions loaded or something). What happens if you try it in incognito mode? – Rob Grzyb Commented Mar 19, 2013 at 13:12
- If using chrome, use the network panel under your developer tools to see what which resources are causing a delay in your loading process. – klewis Commented Mar 19, 2013 at 13:12
- @RobGrzyb version is Version 25.0.1364.172 m; and all extension are disabled – Sergey Commented Mar 19, 2013 at 13:13
- @blachawk network panel how i understand show request, so nothing there – Sergey Commented Mar 19, 2013 at 13:19
- @RobGrzyb in incognito mode i have the same behavior... – Sergey Commented Mar 19, 2013 at 13:25
2 Answers
Reset to default 4I found the cause. If in the background is running some extension, that makes post request. And this request have pending status about 30 sec. Only after it finishes print-dialogue appears. So pending request blocks print dialogue to be opened
In my case it wouldn't even print at all until I refreshed the page, as described here: Chrome: window.print() print dialogue opens only after page reload (javascript).
@noypiscripter's answer solved it for me:
function printPage() {
window.print();
//workaround for Chrome bug - https://code.google./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;
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745178708a4615318.html
评论列表(0条)