如何在 Perl CGI 脚本中使用 google API?

发布于 2024-09-06 01:23:43 字数 252 浏览 3 评论 0原文

google API 示例显示您应该在 head 标记中包含 javascript,但我使用的是 perl 模块 CGI,并且在那里他们建议您使用“print header;”而不是明确地写出标题。

那么,如果我想使用 perl CGI 模块和 google API javascript,正确的方法是什么?

我尝试明确地写出标头,但似乎 perl 模块确实希望我使用标头方法。这似乎是一个常见的用例,但我在网上查找了一些示例,但找不到。任何帮助将不胜感激。

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 headers 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

转身以后 2024-09-13 01:23:43

只需忽略 CGI 文档并使用

顺便说一句,CGI 中的 header 函数打印 HTTP 标头,而不是 HTML 标头。 html 标头由函数 生成start_html。但你不需要使用CGI的内置函数。 CGI 输出应该如下所示(没有 # 部分):

Content-Type: text/html                   # HTTP HEADER

<html>                                    # HTML HEADER
<head>
<script type="text/javascript">           # JavaScript
...
</script>
</head>
...

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>
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文