Я знаю, что вопрос, который я задаю, уже обсуждался здесь. Но я не мог найти никакого определенного решения. Я работаю над проектом в Drupal 7
, где хочу распечатать. У меня есть графики и другое содержимое для печати. Я использовал window.open()
для создания нового окна и добавления всех стилей и js (chart.js
, jquery.js
и т. Д.) В новое окно, чтобы получить стиль. И window.print() для печати. Мой код работает в firefox
и chrome
, но не в IE
. Я прилагаю код, который я использовал ниже.Window.print() не работает, но работает во всех других браузерах
var mywindow = window.open('', 'print', 'scrollbars=1,height=600,width=600');
mywindow.document.write("<html><head><title>Patient Data</title><link rel='stylesheet' type='text/css' href='" + Drupal.settings.basePath + "sites/all/themes/prescribewell/css/style.css'>");
mywindow.document.write("<link rel='stylesheet' type='text/css' href='" + Drupal.settings.basePath + "sites/all/themes/prescribewell/css/bootstrap.css'>");
mywindow.document.write("<link rel='stylesheet' type='text/css' href='" + Drupal.settings.basePath + "sites/all/themes/prescribewell/css/bootstrap.min.css'>");
mywindow.document.write("<link rel='stylesheet' type='text/css' href='" + Drupal.settings.basePath + "sites/all/themes/prescribewell/css/bootstrap-theme.css'>");
mywindow.document.write("<link rel='stylesheet' type='text/css' href='" + Drupal.settings.basePath + "sites/all/themes/prescribewell/css/bootstrap-theme.min.css'>");
mywindow.document.write("<link rel='stylesheet' type='text/css' href='" + Drupal.settings.basePath + "sites/all/themes/prescribewell/css/font-awesome.css'>");
mywindow.document.write("<link rel='stylesheet' type='text/css' href='" + Drupal.settings.basePath + "sites/all/themes/prescribewell/css/font-style.css'>");
mywindow.document.write("<script src='http://code.jquery.com/jquery-1.10.2.min.js'></sc" + "ript>");
mywindow.document.write("<script src='" + Drupal.settings.basePath + "sites/all/themes/prescribewell/js/bootstrap.js'></sc" + "ript>");
mywindow.document.write("<script src='" + Drupal.settings.basePath + "sites/all/themes/prescribewell/js/bootstrap.min.js'></sc" + "ript>");
mywindow.document.write("<script src='" + Drupal.settings.basePath + "sites/all/themes/prescribewell/js/button.js'></sc" + "ript>");
mywindow.document.write("<script src='" + Drupal.settings.basePath + "sites/all/themes/prescribewell/js/prescribewell_leads_js.js'></sc" + "ript>");
mywindow.document.write("<script src='" + Drupal.settings.basePath + "sites/all/modules/Prescribewell_leeds/prescription.js'></sc" + "ript>");
mywindow.document.write("</head><body>");
mywindow.document.write(datas.resPres); //content to be printed as json response...
mywindow.document.write("</body>");
if (summary == 1) {
mywindow.document.write("<script src='http://code.jquery.com/jquery-1.10.2.min.js'></sc" + "ript>");
mywindow.document.write("<script src='" + Drupal.settings.basePath + "sites/all/modules/prescribewell_charts/Chart.js'></sc" + "ript>");
mywindow.document.write("<script src='" + Drupal.settings.basePath + "sites/all/modules/prescribewell_charts/clinicchart.js'></sc" + "ript>");
mywindow.document.write("<script src='" + Drupal.settings.basePath + "sites/all/modules/Prescribewell_leeds/print.js'></sc" + "ript>");
}
mywindow.document.write("</html>");
if (navigator.appName == 'Microsoft Internet Explorer') {
window.print();
} else {
setTimeout(function() {
mywindow.document.close();
mywindow.focus();
mywindow.print();
//mywindow.close();
}, 5000);
}
Заранее спасибо.
предоставьте нам скрипку, пожалуйста, –
. Вам нужно будет рассказать нам, что выявила ваша отладка, а не просто «она не работает». Что происходит? Какие ошибки? Какие эксперименты вы пробовали? –