There are 2 files: index.html
and print.html
First one contains a button that opens print.html
using simple command:
I had similar issue with Chrome - because of the security policy it can't access local files. When I am making an AJAX call I get this error
XMLHttpRequest cannot load file:///*. Origin null is not allowed by Access-Control-Allow-Origin.
From what I know - you should launch Chrome with params:
--allow-file-access-from-files
Hope it helps.
You need to install mod_headers
on Apache and set it on .htaccess
Header add Access-Control-Allow-Origin "*"
there is a Chrome bug where window.print()
does not work when there is a tag in the DOM. It might be solved by calling this function:
function printPage() {
window.print();
//workaround for Chrome bug - https://code.google.com/p/chromium/issues/detail?id=141633
if (window.stop) {
location.reload(); //triggering unload (e.g. reloading the page) makes the print dialog appear
window.stop(); //immediately stop reloading
}
return false;
}
Your server not added ORIGIN headers. You need add it on .htaccess. For example:
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
Or you can add it in PHP on print.html (if you can use PHP on html files)
header ("Access-Control-Allow-Origin: *");
header ("Access-Control-Allow-Headers: origin, x-requested-with, content-type");
header ("Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS");