Print contents of a modal popup

后端 未结 4 1407
眼角桃花
眼角桃花 2020-12-22 07:26

I have an application that shows a list of items.

The user can click on an item and see its details in a modal popup (centered DIV, shown using JavaScript). I need t

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 07:39

    Try this

    function PrintContent() {
    
    var DocumentContainer = document.getElementById('nameofDiv');
    var WindowObject = window.open("", "PrintWindow",
    "width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes");
    WindowObject.document.write();
    WindowObject.document.write('')
    WindowObject.document.writeln(DocumentContainer.innerHTML);
    WindowObject.document.close();
    WindowObject.focus();
    WindowObject.print();
    WindowObject.close();
    }
    

    This will print out the contents in another window using your stylesheets

提交回复
热议问题