The google API example shows that you should have the javascript within the head tag but I am using perl module CGI and in there they suggest that you use "print header;" instead of writting out your header开发者_如何转开发s explicitly.
So if I want to use the perl CGI module and the google API javascript what is the correct way to do this?
I tried writing out the header explicitly but It seemed like the perl module really wanted me to use the header method. It seems like this would be a common use case but I looked around the web for some examples of this and I could not find one. Any help would be appreciated.
Just ignore the CGI documentation and print your own HTML head section with the <script>
section.
By the way, the header
function in CGI prints the HTTP header, not the HTML header. The html header is produced by a function start_html
. But you do not need to use CGI's built-in function. CGI output is supposed to look like the following (without the # parts):
Content-Type: text/html # HTTP HEADER
<html> # HTML HEADER
<head>
<script type="text/javascript"> # JavaScript
...
</script>
</head>
...
精彩评论