echo '
<script type="text/javascript">
setInterval( myfunction , 1000);
myfunction(){
window.location = "../index.php";
}
</script>';
如果我只是在没有setInterval
的情况下致电window.location = "../index.php"
,它确实有效,我已经看到了很多代码,但是没人能帮助我。
如果要在一定的时间后重定向或重新加载网页,则只能将事件触发,以形成客户端。您可以使用Java脚本和HTML元标记来实现此目标。
1:使用HTML
<meta http-equiv="refresh" content="0";url=http://www.domain.com/new-page.html">
您可以将内容的值设置为时间
2:使用JavaScript
<script type="text/javascript">
setInterval(function(){
window.location = "../index.php";
} , 1000);
</script>
1秒钟后重定向页面。它运行一次
<script type="text/javascript">
setTimeout(function(){
window.location = "../index.php";
}, 1000);
</script>
如果您在PHP中写入,请使用
<?php
//code here
?>
<script type="text/javascript">
setTimeout(function(){
window.location = "../index.php";
}, 1000);
</script>
<?php
//code here
?>
或使用setInterval而不是settimeout