web页面打印代码

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

 

<!--关键代码部分-->
<style type="text/css" media=print>
.noprint{display : none }
</style>

<SCRIPT language=javascript> 


  function printsetup(){ 
  // 打印页面设置 
  wb.execwb(8,1); 
  } 


  function printpreview(){ 
  // 打印页面预览       
  wb.execwb(7,1);              
  } 

 

  function printit() 
  { 
  if (confirm('确定打印吗?')) { 
  wb.execwb(6,6) 
  } 
  } 

 

function pagesetup_null(){
  try{
  var RegWsh = new ActiveXObject("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){}
 }
  </SCRIPT>

<!--关键代码部分-->

 

</HEAD>
<BODY>

<DIV align=center> 
  <p>

 

<!--关键代码部分-->
    <OBJECT id=wb height=0 width=0 
classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 name=wb>
    </OBJECT>

<!--关键代码部分-->


    打印内容开始:  </p>
  <p> Many people have asked about the meaning of our name. &quot;Baidu&quot; was inspired by a   poem written more than 800 years ago during the Song Dynasty. The poem compares   the search for a retreating beauty amid chaotic glamour with the search for   one's dream while confronted by life's many obstacles. &quot;…hundreds and thousands   of times, for her I searched in chaos, suddenly, I turned by chance, to where   the lights were waning, and there she stood.&quot; Baidu, whose literal meaning is   hundreds of times, represents persistent search for the ideal.</p>
  <p>打印的内容结束<br />
  </p>


  <p class="noprint">

<!--class="noprint"的作用是标示不需要打印的地方,任何一个标签的class属性都可以设置,用于去除不需要打印的地方-->


<INPUT onclick=javascript:pagesetup_null(),printit() type=button value=打印 name=button_print /> 
<INPUT onclick=javascript:printsetup(); type=button value=打印页面设置 name=button_setup /> 
<INPUT onclick=javascript:printpreview(); type=button value=打印预览 name=button_show /> 
</p>
</DIV>
</body>
</html>

你可能感兴趣的:(JavaScript,Web,function,search,input,button)