duanbeng6709 2011-05-03 07:09
浏览 98

如何刷新执行php代码的div

a group images are calling in a div and there we have given an option to rotate images if required.

Actually the image is rotating but it is not showing in the page( without doing 2 or 3 manual page refresh).

I have added

 <meta HTTP-EQUIV="Pragma" content="no-cache"/>
 <meta HTTP-EQUIV="Cache-Control" content="no-cache"/>

at head

also done

if(isset($_GET['re'])=='re')
{
?>

<script language="JavaScript" type="text/javascript">

var reloaded = false;
var loc=""+document.location;
loc = loc.indexOf("?reloaded=")!=-1?loc.substring(loc.indexOf("?reloaded=")+10,loc.length):"";
loc = loc.indexOf("&")!=-1?loc.substring(0,loc.indexOf("&")):loc;
reloaded = loc!=""?(loc=="true"):reloaded;

function reloadOnceOnly() {
    if (!reloaded)
        window.location.replace(window.location+"?reloaded=true");
}
reloadOnceOnly(); //You can call this via the body tag if desired
</script>

<?php
}

But it is not showing the new rotated or changed image without another manual refresh.

Could you please help me on this?

  • 写回答

2条回答 默认 最新

  • doubo7131 2011-05-03 07:14
    关注

    If I understand you correctly, you're trying to use a PHP to code to refresh the webpage? However, the issue here is that once the PHP is output to the client, you can't have control over it already. The best thing to do in this context is to use JavaScript to do the refresh for you. Hope it helps :)


    Hi Merlin, you might want to use a simpler logic like this:

    <script type="text/javascript">
    
        var reloaded = false;
        var loc=""+document.location;
    
        loc = loc.indexOf("?reloaded=");
    
        if (loc == -1){
          window.location.replace(window.location+"?reloaded=true");      
        }
    </script>
    

    Optionally you might want to pack it into a function for your use. Hope it helps (:

    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?