温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

js ScripX插件打印

发布时间:2020-08-31 21:45:07 阅读:2469 作者:樊泛繁 栏目:开发技术
前端开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

1,ScriptX插件初次使用都要先下载安装,压缩包直接放在项目里庵后运行,打开页面根据提示安装就可以了;

2,在**head中引入**

  @media   screen{.onlyPrint{display:none}}   
  @media   print{.onlyShow{display:none}   .onlyPrint{page-break-before:always}}

然后剩下的js操作就可以了;

3,

function printsetup() {
        // 打印页面设置 
        factory.printing.PageSetup();
    }
    function doPrint() {
    if (confirm('确定打印吗?')) {
        document.all.factory.printing.header = ""//页眉
        document.all.factory.printing.footer = ""//页脚
        //设置边距
        document.all.factory.printing.leftMargin = 19.05;//left
        document.all.factory.printing.topMargin = 19.05;//top
        document.all.factory.printing.rightMargin = 19.05;//right
        document.all.factory.printing.bottomMargin = 19.05;//bottom
        document.all.factory.printing.portrait = false//横向打印
        document.all.factory.printing.Print(false); //只打印当前frame,不管是否隐藏
        }
    }
<center class=aaa>
<input onclick=javascript:printsetup(); type=button value=打印页面设置 name=button_setup /> 
<input onclick=javascript:doPrint(); type=button value=打印 name=button_print /> 
</center>

根据自己实际情况设置初始参数,如需保存更改的打印设置的参数,可以考虑使用JavaScript设置cookie进行操作。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×