0

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.print()">

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

thanks, Sebastian

3 Answers 3

3

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;

}
Sign up to request clarification or add additional context in comments.

4 Comments

Typed it out quickly as I knew someone would come up with it too.
table { display:block; } will break in standards-confirming browsers. The standard display type of tables is table. Also the descendants will need to be "re-displayed", too.
Was just a quick answer as i don't know what elements are showing
i have the same problem here as below. the table i want to print is generated after a form is completed. i have other tables and items on the page that need to be visible.
0

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.

Comments

0

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)

1 Comment

that's a bit harder, i'm using joomla, and the content that i want to make available for print is a table that only appears after a form is completed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.