javascript - window.print() refreshes page in iframe when I click cancel -


i have iframe inside website following jquery code in it:

$(document).ready(function() {      $('#print_button').click(function() {         window.print();     });  }); 

the problem: when click print button, print dialog opens correctly. printing works correctly well. when click cancel button in print dialog closes refreshes content in iframe.

how can avoid behaviour?

as stated in above comments, form being submitted when button #print_button clicked. force page refresh.

to prevent this, add return value of false onclick event. cancel form submission.

window.print(); return false; 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -