I wrote a JavaScript print function for a web page. It extracts HTML from a hidden div on the page, displays it in a new window, and launches the print dialog. A.
This option is provided through buttonwith the event onclick="printTheThing()". I know that, for example, screen readers have some caveats with JavaScript. I am wondering if / how many people, such as the blind or sight, can block the use of this function.
The implementation opens a new browser window and is added to its document:
function printTheThing() {
var dispSettings = "toolbar=yes,location=no,directories=yes,menubar=yes,"
+ "scrollbars=yes,width=550,height=400",
html = $('#theDivToPrint').html(),
printWindow = window.open("", "", dispSettings),
doc = printWindow.document;
doc.open();
try {
doc.write('<html><head>');
doc.write('<title>' + title + '</title>');
doc.write('</head><body>');
doc.write(html);
doc.write('</body></html>');
} finally {
doc.close();
}
printWindow.focus();
printWindow.print();
}
Update: this is what the button looks like:
<button type="button" onclick="printTheThing()">Print the thing!</button>
, CSS . Firefox "". , . Fangs , .