javascript怎么去掉页眉页脚

文章2023-11-1626 人已阅来源:网络

javascript去掉页眉页脚的方法:首先使用javascript中的window.print()功能进行当前页面的打印;然后使用css控制布局去掉页眉页脚即可。

javascript怎么去掉页眉页脚

本文操作环境:windows7系统、javascript1.8.5版、Dell G3电脑。

javascript怎么去掉页眉页脚?

写在前面

今天的开发遇到了使用window.print()功能进行当前页面打印的功能,因为页脚左边部分显示了url,这是不能存在的,已解决,写在这里。

正文

很多网上的方法都是不能用的,最后我找到一个使用css控制布局去掉页眉页脚的方法

<style> @page { size: auto;  /* auto is the initial value */ margin: 0mm; /* this affects the margin in the printer settings */ }
</style>

最后

亲测,谷歌,ie都解决

【推荐学习:javascript高级教程】

以上就是javascript怎么去掉页眉页脚的详细内容!