function printPopupPage(elem)
{
var skinUrl = '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); ?>';
var path = skinUrl+"frontend/enterprise/woodstream/css/styles.css";
var pathlocal = skinUrl+"frontend/enterprise/terro/css/local.css";
var printWindow = window.open('', '', 'height=400,width=751');
printWindow.document.write('<html>');
printWindow.document.write('<link rel="stylesheet" type="text/css" media="all" href="'+path+'" />');
printWindow.document.write('<link rel="stylesheet" type="text/css" media="all" href="'+pathlocal+'" />');
printWindow.document.write('<div class="print">');
printWindow.document.write(jQuery(elem).html());
printWindow.document.write('</div>');
printWindow.document.write('</html>');
//printWindow.location.reload();
printWindow.show();
//printWindow.print();
if (navigator.appName != 'Microsoft Internet Explorer') {
printWindow.close();
}
else
{
window.setTimeout(function() {printWindow.close()}, 3000);
}
}
答案 0 :(得分:0)
如果您要创建元素并将其动态附加到<head>
,我建议您在JavaScript中使用document.createElement()
。
var printWindow = window.open('', '', 'height=400,width=751'),
skinUrl = '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); ?>',
doc = printWindow.document,
woodstream = doc.createElement('script');
woodstream.type = 'text/css';
woodstream.media = 'all';
woodstream.href = skinUrl + 'frontend/enterprise/woodstream/css/styles.css';
(doc.getElementsByTagName('head')[0] || doc.getElementsByTagName('body')[0]).appendChild(woodstream);
// and so on