-5
    print button(
      -name =>'GOOD',
      -value    =>'GOOD',
      -onclick=>'redirect_GMM()'
    );

    sub redirect_GMM()
      {
         print redirect(-url=>'http://localhost/cgi-bin/GMW/GMM.pl');
      } 

我想通过使用 perl 中的 onclick 按钮来重定向页面。

      print "User name:\t";

        print $q->textfield(
              -name => 'UserName',
               -value =>'Google',
               -size  => 15,
               -maxlength =>25,
            ); 
             my $uName = $q->param('UserName');
             print "<script>alert($uName)</script>";

没有得到文本字段的值。

4

1 回答 1

0
      Using the javascript in Perl we can redirect the page from perl file to the another perl file

       Step 1  use CGI qw(:standard);

       Step 2   my $JSCRIPT=<<EOF;

                function redirect_GMM()
                {
                window.location.href = 'http://localhost/cgi-bin/GMW/GMM.pl';
                }   
                EOF
                 ;  
       Step 3  my $q =CGI->new;
               print $q->header('text/html');
               print $q->start_html(-title=>'JJ',-script=>$JSCRIPT);
               print $q->h5('JJ login page');
               print $q->end_html; 

       Step 4   print button(
                         -name =>'GOOD',
                         -value    =>'GOOD',
                         -onclick=>'redirect_GMM()'
                          );

         This code will surely redirect the page when you press the button.
于 2013-09-06T11:30:05.537 回答