Javascript 使用打印媒体CSS删除页眉和页脚

Javascript 使用打印媒体CSS删除页眉和页脚,javascript,printing,media,Javascript,Printing,Media,当我使用window.print打印页面时,它会自动在页眉和页脚中添加一些数据 <title>GM Shop Click Drive Tracker Tool - Reports</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="autho

当我使用window.print打印页面时,它会自动在页眉和页脚中添加一些数据

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->
例如:在页面顶部添加页面标题和本地主机url。在页面底部添加-页码和时间。如何从我的页面中删除这些信息

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->
我的Html页面:

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->
GM车间单击驱动跟踪器工具-报告
身体{
填充顶部:6px;/*60px,使容器一直到达顶部栏的底部*/
}
@媒体印刷品{
输入{
显示:无!重要;
}
.ui帮助程序隐藏可访问{
显示:无!重要;
}
#引水{
显示:无;
}
.侧边栏导航{
显示:无!重要;
}
挑选{
显示:无!重要;
}
.数据表{
宽度:90%!重要;
}
}
表1.1数据列表{
边界塌陷:分离;
边界间距:0;
}
表4.1数据列表th{
背景色:#f0;
}
表4.1.1数据列表tr th,
表1.dataList tr td{
右边框:1px实心#bbb;
边框底部:1px实心#bbb;
填充物:5px;
}
table.dataList tr th:第一个孩子,
table.dataList tr td:第一个孩子{
左边框:1px实心#bbb;
}
表1.dataList tr th{
背景:#eee;
边框顶部:1px实心#bbb;
文本对齐:左对齐;
}
/*左上边界半径*/
table.dataList tr:第一个子项th:第一个子项{
边框左上半径:6px;
}
/*右上边界半径*/
table.dataList tr:第一个子项th:最后一个子项{
边框右上角半径:6px;
}
/*左下边界半径*/
table.dataList tr:最后一个孩子td:第一个孩子{
边框左下半径:6px;
}
/*右下边界半径*/
table.dataList tr:last child td:last child{
边框右下半径:6px;
}   
替补{
背景色:#f0;
}
.亮点{
背景色:#FFFFE0!重要;
}

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->


您也可以转到JS打印特定的
DIV
。下面是一个例子

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->
JS

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->
function printPage(id) {
    var html="<html>";
    html+= document.getElementById(id).innerHTML;
    html+="</html>";
    var printWin=window.open('','','left=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status =0');
    printWin.document.write(html);
    printWin.document.close();
    printWin.focus();
    printWin.print();
    printWin.close();
}
函数打印页(id){
var html=“”;
html+=document.getElementById(id).innerHTML;
html+=“”;
var printWin=window.open(“”,,“left=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
printWin.document.write(html);
printWin.document.close();
printWin.focus();
printWin.print();
printWin.close();
}

您可以在单击事件时调用上述函数。

您将无法删除这些页眉和页脚,因为是浏览器将它们放在那里的。在某些浏览器上,用户可能能够删除页眉和页脚,但由于这需要(精明的)用户的干预,因此这可能不是您正在寻找的解决方案

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->
如果您真的必须自己删除页眉/页脚,那么您唯一的选择似乎是生成PDF输出,然后用户可以打印或保存到磁盘。一些CMS将自动提供此功能(例如Joomla)。如果您正在使用自己的库,请查看以下库:

<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->
  • <title>GM Shop Click Drive Tracker Tool - Reports</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link href="css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
    <style>
      body {
        padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
      }
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet">
    <link href="css/gmpt.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    
    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
    <![endif]-->
    
    <!-- Fav and touch icons -->
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
      <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                    <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                                   <link rel="shortcut icon" href="ico/favicon.png">
    
    <style type="text/css">
    
    @media print {
        input {
            display:none !important;
        }
        .ui-helper-hidden-accessible {
            display:none !important;
        }
        #headRow {
            display:none;
        }
        .sidebar-nav {
            display:none !important;
        }
        select {
            display:none !important;
        }
        .dataList {
            width:90% !important;
        }
    }
    
        table.dataList {
            border-collapse: separate;
            border-spacing: 0;
        }
        table.dataList th {
            background-color: #f0f0f0;
        }
    
        table.dataList tr th,
        table.dataList tr td {
            border-right: 1px solid #bbb;
            border-bottom: 1px solid #bbb;
            padding: 5px;
        }
        table.dataList tr th:first-child,
        table.dataList tr td:first-child {
            border-left: 1px solid #bbb;
        }
        table.dataList tr th {
            background: #eee;
            border-top: 1px solid #bbb;
            text-align: left;
        }
    
        /* top-left border-radius */
        table.dataList tr:first-child th:first-child {
            border-top-left-radius: 6px;
        }
    
        /* top-right border-radius */
        table.dataList tr:first-child th:last-child {
            border-top-right-radius: 6px;
        }
    
        /* bottom-left border-radius */
        table.dataList tr:last-child td:first-child {
            border-bottom-left-radius: 6px;
        }
    
        /* bottom-right border-radius */
        table.dataList tr:last-child td:last-child {
            border-bottom-right-radius: 6px;
        }   
        tr.alternate {
            background-color: #f0f0f0;
        }
        .highlight {
            background-color:#FFFFE0 !important;
        }
    </style>                                   
    
    </div><!-- /container -->
    
  • <title>GM Shop Click Drive Tracker Tool - Reports</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link href="css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
    <style>
      body {
        padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
      }
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet">
    <link href="css/gmpt.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    
    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
    <![endif]-->
    
    <!-- Fav and touch icons -->
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
      <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                    <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                                   <link rel="shortcut icon" href="ico/favicon.png">
    
    <style type="text/css">
    
    @media print {
        input {
            display:none !important;
        }
        .ui-helper-hidden-accessible {
            display:none !important;
        }
        #headRow {
            display:none;
        }
        .sidebar-nav {
            display:none !important;
        }
        select {
            display:none !important;
        }
        .dataList {
            width:90% !important;
        }
    }
    
        table.dataList {
            border-collapse: separate;
            border-spacing: 0;
        }
        table.dataList th {
            background-color: #f0f0f0;
        }
    
        table.dataList tr th,
        table.dataList tr td {
            border-right: 1px solid #bbb;
            border-bottom: 1px solid #bbb;
            padding: 5px;
        }
        table.dataList tr th:first-child,
        table.dataList tr td:first-child {
            border-left: 1px solid #bbb;
        }
        table.dataList tr th {
            background: #eee;
            border-top: 1px solid #bbb;
            text-align: left;
        }
    
        /* top-left border-radius */
        table.dataList tr:first-child th:first-child {
            border-top-left-radius: 6px;
        }
    
        /* top-right border-radius */
        table.dataList tr:first-child th:last-child {
            border-top-right-radius: 6px;
        }
    
        /* bottom-left border-radius */
        table.dataList tr:last-child td:first-child {
            border-bottom-left-radius: 6px;
        }
    
        /* bottom-right border-radius */
        table.dataList tr:last-child td:last-child {
            border-bottom-right-radius: 6px;
        }   
        tr.alternate {
            background-color: #f0f0f0;
        }
        .highlight {
            background-color:#FFFFE0 !important;
        }
    </style>                                   
    
    </div><!-- /container -->
    

这些类能够将HTML文档(或其中的一部分)转换为PDF。它们允许您传入CSS文件,以便确定生成的PDF的布局和样式。根据我的经验,只要你避开(复杂的)表格,它就工作得很好。

这是用户/浏览器控制的,你不能为用户更改它。但是,您可以使用PHP之类的工具将页面上的元素打印为PDF,然后将PDF打印出来,我相信……谷歌这样做:(答案是,如果用户的浏览器没有明确更改某些设置,您就无法强制用户的浏览器打印没有页眉/页脚的内容)@ursitesion在此我无法添加我的html代码。我添加了…请检查并让我知道您是否需要我端的任何内容。您确定这是jQuery?它将创建新网页并发送到打印。您可以添加特定的
div
打印。谢谢sameer。我试试这个。在此之前,我需要知道我们是否可以通过媒体css进行控制。看起来你也缺少了一个花括号。没有什么可以匹配结尾处的括号。为什么需要做所有这些事情,而我们只需要使用CSS就可以管理这些事情。通过使用css,需要隐藏页眉和页脚元素
@media print{}
部分。请参阅此链接
http://stackoverflow.com/questions/7710315/how-to-remove-print-header-footer-with-code
我认为你不能用CSS隐藏打印日期/时间和URL。在您链接到的问题中,似乎也说明了这一点。
<title>GM Shop Click Drive Tracker Tool - Reports</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" media="screen"/>
<style>
  body {
    padding-top: 6px; /* 60px to make the container go all the way to the bottom of the topbar */
  }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/gmpt.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
                <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
                               <link rel="shortcut icon" href="ico/favicon.png">

<style type="text/css">

@media print {
    input {
        display:none !important;
    }
    .ui-helper-hidden-accessible {
        display:none !important;
    }
    #headRow {
        display:none;
    }
    .sidebar-nav {
        display:none !important;
    }
    select {
        display:none !important;
    }
    .dataList {
        width:90% !important;
    }
}

    table.dataList {
        border-collapse: separate;
        border-spacing: 0;
    }
    table.dataList th {
        background-color: #f0f0f0;
    }

    table.dataList tr th,
    table.dataList tr td {
        border-right: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        padding: 5px;
    }
    table.dataList tr th:first-child,
    table.dataList tr td:first-child {
        border-left: 1px solid #bbb;
    }
    table.dataList tr th {
        background: #eee;
        border-top: 1px solid #bbb;
        text-align: left;
    }

    /* top-left border-radius */
    table.dataList tr:first-child th:first-child {
        border-top-left-radius: 6px;
    }

    /* top-right border-radius */
    table.dataList tr:first-child th:last-child {
        border-top-right-radius: 6px;
    }

    /* bottom-left border-radius */
    table.dataList tr:last-child td:first-child {
        border-bottom-left-radius: 6px;
    }

    /* bottom-right border-radius */
    table.dataList tr:last-child td:last-child {
        border-bottom-right-radius: 6px;
    }   
    tr.alternate {
        background-color: #f0f0f0;
    }
    .highlight {
        background-color:#FFFFE0 !important;
    }
</style>                                   
</div><!-- /container -->