function abortPrint() { alert("Printing is not allowed"); document.write(); } code example
Example: function abort Print() { alert("Printing is not allowed"); document.write(); }]
<!DOCTYPE html>
<html>
<body onbeforeprint="abortPrint()">
<p>This is my Content</p>
<script>
function abortPrint()
{
alert("Printing is not allowed");
document.write();
}
</script>
</body>
</html>