0
調用打印功能,我有a.html是JS:從其他文件
a.html
<script>
function printContent(el){
var restorepage = document.body.innerHTML;
var printcontent = document.getElementById(el).innerHTML;
document.body.innerHTML = printcontent;
window.print();
document.body.innerHTML = restorepage;
}
</script>
<div id="div1">DIV 1 content...</div>
<button onclick="printContent('div1')">Print Content</button>
我想打印包含a.html該按鈕b中。 HTML
b.html
<a href="#" onclick="printContent("printJS")">Print</a>
如何將func傳遞給其他文件?
感謝
請參閱:http://stackoverflow.com/questions/4818854/javascript-import-html-is-it-possible。你在做什麼沒有多大意義。你可以將你的函數放在單獨的文件中並導入這些js腳本。 – VSO
您是否嘗試打印其他窗口的內容? –
是的,當然@JaredFarrish如何做到這一點? –