Thread Javascript print() Frage (2 answers)
Opened by Kuerbis at 2011-08-21 19:31

murphy
 2011-08-21 19:55
#151725 #151725
User since
2004-07-19
1776 Artikel
HausmeisterIn
[Homepage]
user image
Das lässt sich leicht durch eine medientypspezifische Stilangabe lösen, zum Beispiel so:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use 5.012;
use warnings;
use utf8;
use CGI;

my $javascript = <<'END';
function printpage() {
    window.print()
}
END
    
my $css = <<'END';
@media print {
    .hideme { display: none; }
}
END

my $cgi = CGI->new();

print $cgi->header( -charset => 'UTF-8' );
print $cgi->start_html(
    -style => {
        -type => 'text/css',
        -code => $css
    },
    -script => { 
        -type => 'text/javascript',
        -code => $javascript
    });

print $cgi->p( 'Hello World' );
print $cgi->start_form();
print $cgi->button( -name => 'button_1', -value => 'Print', -onClick => 'printpage()', -class => 'hideme' );
print $cgi->end_form();
print $cgi->end_html();
When C++ is your hammer, every problem looks like your thumb.

View full thread Javascript print() Frage