+ -
当前位置:首页 → 问答吧 → 用c语言写cgi 刷新页面

用c语言写cgi 刷新页面

时间:2009-03-13

来源:互联网

我在Linux下面配置好了boa web服务器,我现在正用c语言编写cgi程序,在网页上显示。
//hello.c
#include<stdio.h>
int main()
{
  printf("Content-type:text/html\n\n");
  printf("<html><head><title>hello</title></head>\n");
  printf("<body>\n");
  printf("hello!");
  printf("</body>\n");
  printf("</html>\n");
  return 0;  
}
上面是简单的hello程序,经过gcc -o hello hello.c编译后
在网页上输入http://192.168.1.198/cgi-bin/hello后可以显示 hello!
这个程序很简单呵呵。
我现在想问下各位朋友,我怎么在网页上实现每隔一秒钟,在网页上显示当前的系统时间,或者说每隔一秒钟刷新一下网页。
谢谢各位朋友了!

作者: longyiyufei   发布时间: 2009-03-13

这里好冷啊。。。

作者: longyiyufei   发布时间: 2009-03-13

这个可以用Javascript实现呢,
<body onload="setTimeout('window.location.reload()', 300000)">
兄弟我也搞CGI,我的QQ是59943266.
联系一下

作者: BlueBirdssh   发布时间: 2009-04-01

用ajax 请求CGI啊

作者: tyyhong   发布时间: 2009-04-12

你的问题根本不是CGI的范畴。是WEB页面编写的问题。写好WEB页面代码后用C printf就可以了。

作者: walacato   发布时间: 2009-04-14

能给举个例子吗?我不是很会这个,就是web页面申请读数据

作者: longyiyufei   发布时间: 2009-04-14

可以用CGI程序来定时printf

作者: xiaoshun123   发布时间: 2010-04-30

html的meta标签可以实现这个功能,可以用printf写入一个<meta http-equiv="Refresh"
content="5;url=http://www.xxx.com.">,content后面的值是刷新的间隔时间。

作者: Weilancys   发布时间: 2010-07-20