Reputation: 11
It seems that there is no satisfactory JS code available for this.
Have tried the following. It pops up a box and asks for the permission. Can anybody suggest modification in the following code so that printing won't be executed?
<script>
if($(".print-mode").is(":hidden")) {
alert("normal mode");
} else {
alert("print mode");
}
</script>
Also tried:
<style>
.print-mode { display: none;}
@media print {
.print-mode { display: block;}
}
</style>
It didn't work.
Upvotes: 0
Views: 1945
Reputation: 1554
Please write your code following way :
<script>
$( document ).ready(function() {
if($(".print-mode").is(":hidden")) {
$(this).attr("disabled","disabled");
}
else {
$(this).removeAttr("disabled");
}
});
</script>
Upvotes: 0
Reputation: 138
You can't control with browser actions
the possible solution is
<style type="text/css">
@media print{
body {display:none;}
}
</style>
no other stopping mechanism
Upvotes: 2