I want to Print receipt page on loading page in firefox
Firefox shows following error..
Use of getPreventDefault()
is deprecated. Use defaultPrevented instead.
error source line:
src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMWindow.print] error source line:
print();
code:
$(document).ready(function() {
print_doc();
$("#Submit").click(function() {
$("#goBack").hide();
$("#printRow").hide();
print();
$("#goBack").show();
$("#printRow").show();
});
});
function print_doc() {
$("#goBack").hide();
$("#printRow").hide();
print();
$("#goBack").show();
$("#printRow").show();
}
I want to print my receipt before showing "goBack", and "printRow" id's but not working
Upgrade both your versions of Firefox & jQuery version from 1.6.4
to a more recent version.
This was filed as a bug in Firefox in FF11 & Patched as a result:
Bug #707677: getPreventDefault(); deprecated
As after all, the error messages refer to lines of source code that are completely unrelated to your code.
you can create new css with media type print
<style media="print">
#goBack,#printRow {
display:none;
}
</style>
used this code
print :
Intended for printed documents (applies to docs viewed in print preview mode too).
I also get this warning in the latest FF and jQuery. Don't worry about it, it'll get fixed upstream before it causes any problems.
As for your code, try this:
$(document).ready(function() {
$("#Submit").click(function() {
var btns = $('#goBack, #printRow');
btns.hide(function () {
window.print();
btns.show();
});
});
});
.hide() is asynchronous, meaning that the next line of code may be executed before the browser has had a chance to execute it. So you might be printing before the elements are hidden. By sticking the print inside of .hide()'s callback, you are sure it is hidden when you print.
As another poster mentioned, though, CSS media types are probably a better way to do this:
@media print {
#goBack, #printRow {
display: none;
}
}
it resolved by replacing the latest version of js , visit jquery site and replace with the latest jquery if required .map js too
User contributions licensed under CC BY-SA 3.0