打印特定div的javascript代码 [英] javascript code for print specific div

查看:57
本文介绍了打印特定div的javascript代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script type="text/javascript">

function printDiv() {
var DocumentContainer = document.getElementById('invc');
var WindowObject = window.open('', 'PrintWindow', 'width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes');
var strHtml = "<html>\n<head>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\">\n</head><body><div style=\"testStyle\">\n"
+ DocumentContainer.innerHTML + "\n</div>\n</body>\n</html>";
WindowObject.document.writeln(strHtml);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();

}</script>

<asp:Button ID="Button4" runat="server" Text="Print" OnClientClick="printDiv()" />


ic时
舔Button4,打印视图显示,但divinvc包含图像,该图像未显示在打印视图上



访问此链接以了解更好< br $> b $ b

http://postimg.org/image/6f7h7ymi5/


when i click on Button4,the print view is shown,but the div "invc" contain image ,that image is not shown on print view

visit this link to understand better

http://postimg.org/image/6f7h7ymi5/

推荐答案

我刚试过你的代码。它工作正常并在打印对话框中显示图像。



演示 - [演示]打印带图像的对话框 [ ^ ]。
I just tried your code. It is working fine and showing image inside the Print Dialog.

Demo - [Demo] Print Dialog with Image[^].


这篇关于打印特定div的javascript代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆