web局部打印、去页眉页尾、兼容IE、Firefox、Chrome
来源:互联网 发布:淘宝 论文代发 卓越 编辑:程序博客网 时间:2024/05/15 10:30
web局部打印、去页眉页尾、兼容IE、Firefox、Chrome
这两天需要用到的几个功能。
其中之一呢,就有局部打印,局部打印以前就做过了,不过还是有缺陷的,那就是不能去掉页眉页末。
这次能,就一并解决掉了。
主要思路:
首先区分游览器,我自己开发喜欢使用Firefox,一般情况下,大众使用的是IE、360等,这些都是IE内核的。
另外还有Chrome也占有一大部分的比例。所以总体上就分这三款游览器了。
直接上代码
<script type="text/javascript"> var HKEY_Root, HKEY_Path, HKEY_Key; HKEY_Root = "HKEY_CURRENT_USER"; HKEY_Path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; function jqprintDiv() { //打印初始化 var isIE = /msie/.test(navigator.userAgent.toLowerCase()); //jquery1.9之后采用 //var isIE = $.browser.msie;//jquery1.9之前采用 if (isIE) { //IE浏览器执行 printitIE('PrintArea'); } else { //其他浏览器执行通用打印 $("#PrintArea").jqprint(); } } function printitIE(MyDiv) { PageSetup_Null(); //提示窗口 if (confirm('确定打印吗?')) { var newstr = document.getElementById(MyDiv).innerHTML; document.body.innerHTML = "<div style='position:absolute;left:20px;top:20px;'>" + newstr + "</div>"; window.print(); return false; } } function PageSetup_Null() { try { var Wsh = new ActiveXObject("WScript.Shell"); HKEY_Key = "header"; Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, ""); HKEY_Key = "footer"; Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, ""); } catch (e) { } }</script>
参考地址:http://jingyan.baidu.com/article/fc07f9891f3d6712ffe51912.html
0 0
- web局部打印、去页眉页尾、兼容IE、Firefox、Chrome
- web打印去页眉页脚
- pasteHTML兼容ie,firefox,chrome
- FLASH兼容IE FireFox Chrome
- event 兼容调用(IE,Firefox,Chrome)
- js操作select 兼容ie、chrome、Firefox
- 回到顶部代码,兼容IE CHROME FIREFOX
- pasteHTML兼容ie,firefox,chrome等浏览器
- 兼容IE-FireFox-Chrome的背景音乐播放
- 兼容IE-FireFox-Chrome的背景音乐播放
- jquery.PrintArea 局部打印 去掉页眉页脚,但在IE有些版本中不管用。
- javascript 打印 iframe 内容, 兼容 IE FireFox
- web开发中的打印功能,如何去掉chrome浏览器的页眉页脚
- JS在新标签页中打开链接URL,兼容IE,Chrome,Firefox
- javascript解析xml文件。兼容IE、firefox、Chrome
- 兼容ie,firefox,chrome的跨域加载js脚本
- JavaScript无提示关闭窗口(兼容IE/Firefox/Chrome)
- js动态添加、删除表格,兼容IE、FireFox、Chrome
- Netty 之 AttributeMap属性
- Sencha Touch开发心得分享
- 关于 23 种设计模式的有趣见解
- eclispe不出log
- 人脸检测——HyperFace
- web局部打印、去页眉页尾、兼容IE、Firefox、Chrome
- redisUtils
- C++ 经典面试题
- PreparedStatement批量处理和事务代码
- IllegalStateException :the specified child already has a parent
- 【Unity Shader入门精要】数学基础 — 点和矢量
- jsp1.0传统自定义标签详解
- 透明状态栏
- logback 常用配置详解(三) <filter>