这是我使用的代码,它在firefox和chrome中工作得很好,不幸的是safari不支持这个对话框在出现后立即关闭。任何解决这个问题的方法?
var mywindow = window.open('', 'PRINT', 'height=400,width=600');
mywindow.document.write(
'<html style="background-color: white;"><head><title></title>');
mywindow.document.write(
'<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/queue.css">'
);
mywindow.document.write(
'</head><body style="background-color: white !important;padding-top:15px;margin:2">'
);
mywindow.document.write(document.getElementById('forprint').innerHTML);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10*/
mywindow.print();
mywindow.close();
return true;
答案 0 :(得分:1)
var newWindow = window.open();
var url = "[YOURURL]";
service.getUrl().then(function(url) {
newWindow.location = url;
});