javascript - printing a HTML form - Stack Overflow

I am trying to print a page using javascript, it works fine but the issue es with a page havign form in

I am trying to print a page using javascript, it works fine but the issue es with a page havign form inside it. If we print the form values being printed are fine but what we get is html controls (like input ,dropdown) are also being printed. Can some one have any other idea except server side processing

I am trying to print a page using javascript, it works fine but the issue es with a page havign form inside it. If we print the form values being printed are fine but what we get is html controls (like input ,dropdown) are also being printed. Can some one have any other idea except server side processing

Share Improve this question asked May 13, 2009 at 13:03 munity wiki
Gripsoft
Add a ment  | 

3 Answers 3

Reset to default 7

You can attach a print stylesheet to your pages like so...

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

Then in the print stylesheet you can specify...

input, select
{
    display: none;
}

This will hide your form control elements but only when the page is printed. You can extend this by also hiding navigation and links i.e. anything that is not useful on a printed version of your web page

EDIT: As rightly pointed out if you want to still display values within textboxes etc you can set the border-style property to "none" (+ any style declarations that you see fit) and only hide elements that serve no purpose when printed such as buttons

You can provide different css for print and screen display.

In your print css you can probably get rid of most of the html controls visible parts by setting borders to nothing, background to white and so on. I have not tried getting rid of everything this way though, so you may still end up with the odd bit. Worth a try though.

Yes. You'll have to define a different CSS style that will support media="print". CSS intended for print will hide appropriate controls and display static fields.

  • W3C - http://www.w3/TR/CSS2/media.html
  • browser support: http://www.codestyle/css/media/print-BrowserSummary.shtml

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745284749a4620493.html

相关推荐

  • javascript - printing a HTML form - Stack Overflow

    I am trying to print a page using javascript, it works fine but the issue es with a page havign form in

    5小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信