I'm new to Perl, and I'm trying to include a CSS file in a perl-generated html page, how can I do that with cgi ? it should be something like print $cgi -> start_html( -link => { -href => '/styles/main.css', -rel => 'stylsheet', -type => 'text/css'});
Here's the full code,
#!C:\Dwimperl\perl\bin\perl.exe
use CGI;
my $cgi = new CGI;
# ###----- GETTING THE SCRIPTS AND STYLES ------###
my $jquery = "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js";
# ###----- PRINTING THE PAGE -----###
print $cgi -> header;
print $cgi -> start_html(
-title => "TestTitle",
-link => { -href => '/styles/main.css', -rel => 'stylsheet', -type => 'text/css'},
-script=> [{-language => 'javascript',-src => $jquery},{-code => $jscript}],
);
print $cgi -> h1({-class=>"title",-align=>"center"},"Zero Testing");
print $cgi -> start_div({-align=>"center"});
print $cgi -> start_div({-align=>"center",-style=>"margin-bottom:35px;"});
print $cgi -> a({-class=>"linkButton",-id=>"btn_Page",-href=>"Test.pl"},"Suites Page");
print $cgi -> end_div;
print $cgi -> start_form({-method=>"get",-id=>"dataForm"});
print $cgi -> end_form;
print $cgi -> end_div;
print $cgi -> end_html();
Thanks
You could write this:
use CGI qw/:standard/;
# ...
print $cgi->start_html(
-title =>"TestTitle",
-script=> [ {-language => 'javascript',-src => $jquery}, {-code => $jscript} ],
-head => [
Link( { -href => '/styles/main.css', -rel => 'stylsheet', -type => 'text/css'}),
]
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.