分享你我的心得.
共乘一片美好网络.

打印函数开始结束

<script language=”javascript” type=”text/javascript”>

function preview()

{

bdhtml=window.document.body.innerHTML;

sprnstr=”<!–startprint–>”;//设置开始标记

eprnstr=”<!–endprint–>”;//设置结束标记

prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);

prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));

window.document.body.innerHTML=prnhtml;

//以下可以设置打印的样式    window.document.body.style.backgroundColor = ‘#ffffff’;

//window.document.body.style.color = ‘#000000’;

window.print();

}

</script>

 

 

<input type=”button” name=”print” value=”预览并打印” onclick=”preview()” />

<!–startprint–>打印开始

此处放需要打印的部分内容

<!–endprint–>打印结束

 

如果显示错误,有可能和你的JQ脚本冲突,屏蔽或是修改函数

赞(0)
未经允许不得转载:小叶白龙博客 » 打印函数开始结束
分享到: 更多 (0)

评论 15

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址