About JavaScript Print Remove header footer

Source: Internet
Author: User

Because of this problem, Google and Baidu have checked, the main solution on the Internet is this code:

<script language= "JavaScript" >varHkey_root,hkey_path,hkey_key;hkey_root= "HKEY_CURRENT_USER"; Hkey_path= "\\Software\\Microsoft\\Internet explorer\\pagesetup\\";//Set page header footer to print is emptyfunctionPagesetup_null () {Try{  varRegwsh =NewActiveXObject ("Wscript.Shell"); Hkey_key= "Header"; Regwsh.regwrite (Hkey_root+hkey_path+hkey_key, ""); Hkey_key= "Footer"; Regwsh.regwrite (Hkey_root+hkey_path+hkey_key, "");}Catch(e) {alert (e);}}//set the page header footer to print to the default valuefunctionPagesetup_default () {Try{  varRegwsh =NewActiveXObject ("Wscript.Shell"); Hkey_key= "Header"; Regwsh.regwrite (Hkey_root+hkey_path+hkey_key, "&w&b page, &p/&p"); Hkey_key= "Footer"; Regwsh.regwrite (Hkey_root+hkey_path+hkey_key, "&u&b&d");}Catch(e) {alert (e);}}functionPrintmethod () {pagesetup_default (); Window.print ();}</script>

But I tried, do not take effect, I do not know whether my project code is wrong, or the online code has a problem. Anyway all kinds of ways have tried, how JavaScript also has CSS control, and then egg.

Finally found that the Web printing generated header footer, is the browser settings, not our engineering code problems , so long as the browser is set to close the header and footer, you can!

Attached: The browser cancels the header and footer settings

IE browser (IE6 later): tool (upper right corner of the page), print, page setup, uncheck the header and footer all options in the page setup

Chrome: Tool (top right corner three dots), print, single "More Settings" on print page, uncheck ' Header footer '

About JavaScript Print Remove header footer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.