第一种:方法打印并去掉不像打印的地方

<!doctype html>  
<html>  
<head>  
<meta charset="utf-8">  
<title>无标题文档</title>  
</head>  
<style>  
.printonly{  
    display:none  
}  
@media print{  
    input,.noprint{  
        display:none  
    }  
    .printonly{  
        display:block;  
        width:50%  
    }  
}  
/**  
.printonly{  
    display:none  
}  
不能写到这里,会导致打印时printonly的内容也不显示  
*/  
</style>  
  
<body>  
<div class="noprint">  
    这段打印时不显示  
</div>  
<div class="printonly">  
    <h1>这段打印时会显示</h1>  
    <hr>  
    This is print-only  
</div>  
<input onClick="print()" value="点击打印" type="button">  
</body>  
</html>

第二中方法:用meadroid控件对页面进行设置,可自由定制页眉页脚,去掉页面底部的URL

<object id="factory" style="display:none" viewastext classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360"></object>

<title>页面设置</title>
<input  type="button" value="页面设置"
onclick="factory.printing.PageSetup()">
<input type="button" value="打印预览"
onclick="factory.printing.Preview()">

<script>
function window.onload() {
  factory.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页"
  factory.printing.footer = "(自定义页脚)"
  factory.printing.leftMargin = 0.75
  factory.printing.topMargin = 1.5
  factory.printing.rightMargin = 0.75
  factory.printing.bottomMargin = 1.5
  }
</script>
Last modification:January 11, 2020
如果觉得我的文章对你有用,请随意赞赏