CGI使用技巧之一(跳转、自动刷新)
时间:2008-01-02 来源:chinaseen
1、Perl编写CGI程序时,如果要使用redirect进行页面跳转,则在调用redirect()之前不能输出网页头部,如header()和start_html(),否则将不进行跳转,而显示该代码。
print $cgi_ob->redirect('index.pl?error=cannot connect the DB.');
2、如果需要网页进行自动刷新,将新的内容显示出来,只需在
print header(-type=>"text/html",-charset=>"gb2312");
print start_html(-title=>"hello");
后加上:
print "<META HTTP-EQUIV='Refresh' CONTENT='60; URL=index.pl'>";
其中,CONTENT为刷新时间,URL为访问的页面。
print $cgi_ob->redirect('index.pl?error=cannot connect the DB.');
2、如果需要网页进行自动刷新,将新的内容显示出来,只需在
print header(-type=>"text/html",-charset=>"gb2312");
print start_html(-title=>"hello");
后加上:
print "<META HTTP-EQUIV='Refresh' CONTENT='60; URL=index.pl'>";
其中,CONTENT为刷新时间,URL为访问的页面。
相关阅读 更多 +