+ -
当前位置:首页 → 问答吧 → 关于利用meta刷新网页的问题

关于利用meta刷新网页的问题

时间:2011-10-17

来源:互联网


我的网页想自动完成一次刷新,实现方法:

<meta http-equiv="refresh" content="10" />

尽管可以完成刷新,但是它会不停的每隔10秒就刷新一次,而我想只刷新一次或者两次。

请问该如何实现,多谢!

作者: tcssg0206   发布时间: 2011-10-17

PHP可以这样:
PHP code

<?php
if($_COOKIE['refresh_times'] < 5){
?>
<meta http-equiv="refresh" content="10" />
<?php
setcookie('refresh_times',++$_COOKIE['refresh_times']);
}
?>


或者也可以JS

作者: moocky   发布时间: 2011-10-17

报错了,有劳指教:

Warning:Cannot modify header information - headers already sent bu (output started at c:\123.php:12) in c:\123.php on line 25

其中第12行是
<?php php程序的开始
第25行是
setcookie('refresh_times',++$_COOKIE['refresh_times']);

程序就执行一个打开文件的功能,功能模块是对的。

作者: tcssg0206   发布时间: 2011-10-17

<?php
if($_COOKIE['refresh_times'] < 5){
?>
<?php
setcookie('refresh_times',++$_COOKIE['refresh_times']);
}
<meta http-equiv="refresh" content="10" />

?>


引用 2 楼 tcssg0206 的回复:

报错了,有劳指教:

Warning:Cannot modify header information - headers already sent bu (output started at c:\123.php:12) in c:\123.php on line 25

其中第12行是
<?php php程序的开始
第25行是
setcookie('refresh_times……

作者: ci1699   发布时间: 2011-10-17

上面错了。

作者: ci1699   发布时间: 2011-10-17

PHP code

<?php
if($_COOKIE['c'] < 5){
setcookie('c',++$_COOKIE['c']);
echo $_COOKIE['c'];
echo '<meta http-equiv="refresh" content="1" />';
}
?>






应该可以才对

作者: ci1699   发布时间: 2011-10-17

相关阅读 更多

热门下载

更多