• js打印


    function printThis(){
    //    console.log(jQuery("#if1",parent.window.document));
    //    alert(window.parent.document.frames['if1']);
       if (!!window.ActiveXObject || "ActiveXObject" in window){
    //        alert(window.parent.frames['if1']);
    //        alert("IE");
            var bdhtml=window.document.body.innerHTML;
            var sprnstr="<!--startprint-->"; //开始打印标识字符串有17个字符
            var eprnstr="<!--endprint-->"; //结束打印标识字符串
            var prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); //从开始打印标识之后的内容
            var prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); //截取开始标识和结束标识之间的内容
            window.document.body.innerHTML=prnhtml; //把需要打印的指定内容赋给body.innerHTML
            window.parent.document.frames['if1'].focus();
    //        jQuery("#if1",window.parent.document).focus();
    //        window.frames['if1'].focus();
    //        document.execCommand('print', false, null);
            print(); //调用浏览器的打印功能打印指定区域
            window.document.body.innerHTML=bdhtml;//重新给页面内容赋值;
        }else{
    //        $("#wrap").jqprint();
    //        alert(window.frames['if1']);
            var bdhtml=window.document.body.innerHTML;
            var sprnstr="<!--startprint-->"; //开始打印标识字符串有17个字符
            var eprnstr="<!--endprint-->"; //结束打印标识字符串
            var prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); //从开始打印标识之后的内容
            var prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); //截取开始标识和结束标识之间的内容
            window.document.body.innerHTML=prnhtml; //把需要打印的指定内容赋给body.innerHTML
            window.print(); //调用浏览器的打印功能打印指定区域
            window.document.body.innerHTML=bdhtml;//重新给页面内容赋值;
        }
    }
  • 相关阅读:
    linux crontab 定时使用方法
    crontab 选择编辑器 select-editor
    设置定时任务为每天凌晨2点执行和每小时执行一次
    性能测试工具--SIEGE安装及使用简介 siege压力测试
    Vue基础
    使用 supervisor 管理进程
    长按listview弹出选项列表对话框
    左右滑动弹窗之间短信内容区域来显示上一条和下一条短信
    在开机广播中启动服务
    Android spinner 样式及其使用详解
  • 原文地址:https://www.cnblogs.com/web520/p/6879386.html
Copyright © 2020-2023  润新知