0
CGI.pm을 사용하여 다음 HTML을 작성하려합니다. 단순히 2 개의 프레임 만 포함합니다. (같은CGI.pm을 사용하여 링크 이름을 지정하는 방법
--------------------------------
Frame1 |
link1 | Frame2
link2 |
etc |
---------------------------------
사용자는 프레임 1에 링크를 클릭하고 결과는 2
내가 프레임 1에서 CGI 스크립트의 등 "링크 1"의 이름을 원하는하려면 프레임에 나타납니다 쿼리), 그리고 Frame2에 (응답으로) 나타납니다. CGI에서이를 달성하는 방법을 모르겠습니다. 다만 이렇게 당신의 서브 print_query에서
#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
my $TITLE = "My title";
my $query = new CGI;
my $path_info = $query->path_info;
print $query->header();
$path_info = $query->path_info();
# If no path information is provided, then we create
# a side-by-side frame set
if (!$path_info) {
&print_frameset;
exit 0;
}
&print_html_header;
&print_query if $path_info=~/query/;
&print_response if $path_info=~/response/;
&print_end;
sub print_html_header {
print
$query->start_html(-title =>'My title',
-bgcolor=> "F5F5EB",
-style => {
-src => '../print.css',
-align=>'center',
}
),p;
}
sub print_end {
print $query->end_html;
}
# Create the frameset
sub print_frameset {
my $script_name = $query->script_name;
print <<EOF;
<html><head><title>$TITLE</title></head>
<frameset cols="35,65" frameborder=0 marginwidth=0 noresize>
<frame src="$script_name/query" name="query">
<frame src="$script_name/response" name="response">
</frameset>
EOF
;
exit 0;
}
sub print_query {
$script_name = $query->script_name;
print "<H1>Frame1</H2>\n";
# This is where I want to name "Link1" so that
# it can be called later in response frame
# But this doesn't seem to work
print h3("Link1", -name =>'link1");
}
sub print_response {
print "<H1>Frame2</H2>\n";
# If name == link1 do something...
}