分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

js控制打印页眉页脚日期网站

发布时间:2023-09-06 02:13责任编辑:白小东关键词:js

<!DOCTYPE html>
<html>
<head>
???<title>打印</title>
???<meta charset="utf-8">
???<style>
???????.printBox {
???????????width: 300px;
???????????height: 300px;
???????????border: 1px solid blue;
???????}
???</style>
???<!-- 打印的样式-->
???<style media="print">
???????@page {
???????????size: auto;
???????????margin: 0mm;
???????}
???</style>
</head>

<body>
<div class="printBox">
?this is content!!!<br>
???点击按钮打印
</div>
<button onclick=‘print_page()‘>打印</button>
</body>

<script type="text/javascript">
???function print_page() {
???????if (!!window.ActiveXObject || "ActiveXObject" in window) { //是否ie
???????????remove_ie_header_and_footer();
???????}
???????window.print();
???}

???function remove_ie_header_and_footer() {
???????var hkey_path;
???????hkey_path = "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
???????try {
???????????var RegWsh = new ActiveXObject("WScript.Shell");
???????????RegWsh.RegWrite(hkey_path + "header", "");
???????????RegWsh.RegWrite(hkey_path + "footer", "");
???????} catch (e) {
???????}
???}
</script>
</html>

上面是用js控制 

还可以直接在打印页面设置就行了

js控制打印页眉页脚日期网站

原文地址:https://www.cnblogs.com/leegj/p/9583618.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved