I would like to do a post impression action, ie only when the user confirms the impression that the javascript will execute a scheduled event. If I put an event under window.print()
javascript executes even without the user having printed yet. Something like:
window.print() = function(){
[...]
}
I heard about matchMedia
, but I did not understand. Would you like to exemplify from the code below?
1) Before printing I want the background of the yellow screen;
2) After printing I want the background of the green screen;
<html>
<head>
<title>teste</title>
<script>
function imprimir() {
window.print()
}
</script>
</head>
<body>
<input type="button" value="imprimir" onclick="imprimir()" />
</body>
</html>