[英]how to print another page from the current page?
我需要打印與當前頁面不同的頁面,即更准確地描述我的問題.. 我需要將打印按鈕放在一個頁面但需要打印不同的頁面,還需要向第二頁發送一個值這是要打印的。 如果有人可以幫助我將非常感激
將鏈接 go 鏈接到您需要打印的頁面,並在查詢字符串中包含一些信息。 然后將 javascript 放在 onLoad 事件中,用於指示頁面打印的正文。
只需將要打印的頁面放入一個看不見的 iframe 中:
<iframe src="to_print.html" name="frame1"></iframe>
<input type="button" onclick="frames['frame1'].print()" value="print!">
您可以將要打印的頁面加載到(可能是隱藏的)iframe 中,然后在該框架上調用 window.print function。 使用 jquery 會是這樣的(未測試):
$('#printButton').click(function(evt) {
evt.preventDefault();
$('body').append('<iframe src="document_to_be_printed.php?param=value" id="printIFrame" name="printIFrame"></iframe>');
$('#printIFrame').bind('load',
function() {
window.frames['printIFrame'].focus();
window.frames['printIFrame'].print();
}
);
});
在我的腦海中,我可以執行以下操作:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.