如何刷新正在执行php代码的div
一组图像在 div 中调用,我们提供了一个在需要时旋转图像的选项。
实际上图像正在旋转,但它没有显示在页面中(没有进行 2 或 3 次手动页面刷新)。
添加
<meta HTTP-EQUIV="Pragma" content="no-cache"/>
<meta HTTP-EQUIV="Cache-Control" content="no-cache"/>
我已在头部
也已完成,
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
}
但如果没有再次手动刷新,它不会显示新的旋转或更改的图像。
你能帮我解决这个问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不呢
Why not
如果我理解正确的话,您是在尝试使用 PHP 编码来刷新网页吗?然而,这里的问题是,一旦 PHP 输出到客户端,您就无法控制它了。在这种情况下,最好的办法是使用 JavaScript 为您进行刷新。希望它有帮助:)
嗨 Merlin,您可能想要使用像这样的更简单的逻辑:
或者您可能想要将其打包到一个函数中以供您使用。希望它有帮助(:
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:
Optionally you might want to pack it into a function for your use. Hope it helps (: