我不太熟悉CGI.pm语法。
我试着创建html_header,但是我就是不能让它工作。我需要http_equiv和javascript。标题在没有-script部分的情况下工作正常。我到底做错了什么?
print $cgi->start_html(
-head => meta({
-http_equiv => "Refresh",
-content =>"$viive;URL=http://192.168.1.42/saldo/index.cgi?varasto=$varasto"
}),
-title => 'Varasto '.$varasto,
-style => { -src => 'infotaulu.css' }
-script => {
-language => 'javascript',
-src => '/sorttable.js'
);发布于 2013-09-24 17:18:01
您的问题是错过了-style参数末尾的逗号。使用以下命令:
print $cgi->start_html(
-head => $cgi->meta({
-http_equiv => "Refresh",
-content =>"$viive;URL=http://192.168.1.42/saldo/index.cgi?varasto=$varasto"
}),
-title => 'Varasto '.$varasto,
-style => { -src => 'infotaulu.css' },
-script => {
-language => 'javascript',
-src => '/sorttable.js'
}
);给出了以下输出:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Varasto varasto</title>
<meta http-equiv="Refresh" content="viive;URL=http://192.168.1.42/saldo/index.cgi?varasto=varasto" />
<link rel="stylesheet" type="text/css" href="infotaulu.css" />
<script src="/sorttable.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>我想这就是你想要的。
,然而,,我真的认为你应该重新考虑你的方法。在CGI.pm中使用HTML生成函数是一个糟糕的想法。你最终会得到一堆可怕的、不可维护的代码。请考虑改用templating system。
https://stackoverflow.com/questions/18974588
复制相似问题