Javascript 在iFrame中打印后是否有方法发送警报?
在iFrame中打印后是否有方法发送警报 这是代码。我的代码在iFrame中:Javascript 在iFrame中打印后是否有方法发送警报?,javascript,php,iframe,printing,Javascript,Php,Iframe,Printing,在iFrame中打印后是否有方法发送警报 这是代码。我的代码在iFrame中: function print() { var objFra = document.getElementById('pdf_name'); objFra.contentWindow.focus(); objFra.contentWindow.print(); } 我试过了 objFra.contentWindow.addEventListener('afterprint', () =&
function print() {
var objFra = document.getElementById('pdf_name');
objFra.contentWindow.focus();
objFra.contentWindow.print();
}
我试过了
objFra.contentWindow.addEventListener('afterprint', () => { alert('This document is now being printed })
但警报未显示。请尝试以下操作:
var objFra = document.getElementById('pdf_name');
objFra.contentWindow.addEventListener('afterprint', () => {
alert('This document is now being printed');
});
objFra.contentWindow.focus();
objFra.contentWindow.print();
在哪里发送警报?你的意思是在屏幕上显示
alert()
?是的,它尝试了objFra.contentWindow.addEventListener('afterprint',()=>{alert('This document's now printed}),但它没有返回警报我已经尝试了该代码,但整个身体都在打印,而不是我想要的iframe