0
Well I created a printing function in jQuery, when running it hides from the menu div and prints the page. It works perfectly, but in some browser like IE and iPhone safari it doesn’t work.
I noticed that the error occurs because of the function of displaying the menu again after printing. I think one way to solve this is to have the menu displayed in the callback of the print. Someone knows how to do this?
Follows the code:
/* Função para imprimir */
function imprimir() {
// Remove Menu topo
$(".header").hide();
$(".sidenav").hide();
$(".shadow-full").hide();
$(".relatorio caption").show();
$('body').css({"padding-top": "0px"});
// Imprime a página
window.print();
// Adiciona Menu topo
$(".relatorio caption").hide();
$(".header").show();
$('body').css({"padding-top": "40px"});
}
You’re printing with the Divs that should be hidden, right? Wouldn’t it be the case to re-display only after printing?
– Thiago Santos
Yes she is displaying at print time. Good I have to make her come back after printing.
– Hugo Borges
Try using . Promise() - https://api.jquery.com/promise/
– Thiago Santos
Can you post an example? if it works already mark your answer.
– Hugo Borges
Instead of hiding the elements when printing with js, use only css to show in the print only what you want.
– LLeon
how do I do that?
– Hugo Borges
See in the answer if it suits you. I think quieter than using js.
– LLeon