开发者

web printing, php or javascript

how can i print a web page? more exactly i want to print only a table in the web-page.

i found out how to print all the page, some thing like this: <A HREF="javascript:window.pri开发者_高级运维nt()">

i realy don't know javascript. can i modify this to javascript:table.print()?

thanks, Sebastian


You could create a stylesheet (that is used for printing) that only shows the table.

Include it as:

<link rel="stylesheet" href="print.css" type="text/css" media="print"  />

(This would solve printing only the table, if thats all you wanted them to be able to print out)

Css would be something like:

* {
  display:none;
}
table {
  display:block;

}

Or

div, p (list elements here){
  dislay:none;
}

Or

* {
  visibility:hidden;
}
table,tr,td {
  visibility:visible;

}


You can use a CSS style sheet to print what you want by adding it to your to your page and setting the media attribute of the stylesheet tag to print. So to print your table you could hide all the elements on the page apart from your table.


A simple solution is to generate a web page with only the element(s) you want to print and call window.print()

(there is no table.print)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜