【问题标题】:Meta refresh won't refresh元刷新不会刷新
【发布时间】:2012-08-06 04:57:16
【问题描述】:

是否需要让您的元刷新线高于您的</head> 线?就我而言,我不能,因为我必须解析一些变量来指示页面自动刷新的秒数。所有这些都发生在我的页面中间,我也把这个标签放在中间。我的成功率一直很好,但有时根本不会刷新。

我可以使用任何其他刷新代码来保证 100% 的成功率吗?

我在这里使用的标签是:

<meta http-equiv="refresh" content="<?=$now['rsecs'];?>" url="&session<?=rand(1,999999999999)?>">

【问题讨论】:

  • 看来你的语法错误check this
  • 我很确定这需要在&lt;head&gt;&lt;/head&gt; 标签之间。但是有一个问题,为什么需要更改刷新率?
  • 是的,&lt;meta&gt; 标签应该在头部。但是,如果您将它们放在正文中,许多浏览器不会出错 - 但它们确实需要 正确 &lt;meta&gt; 标签,而您的标签不是:developer.mozilla.org/en/HTML/Element/meta#attr-http-equiv

标签: php html page-refresh


【解决方案1】:

你的语法错误:

<meta http-equiv="refresh" content="<?php echo $now['rsecs'];?>;URL='&session=<?php echo rand(1,999999999999);?>'">

我不确定仅将 &session 添加到 url 路径是否会将您发送到正确的位置。也许包括完整的网址?

URL='http://www.your-site.com/page.html?othervars=othervals&session=<?php echo rand(1,999999999999);?>

【讨论】:

  • 我真的不需要 url - 我添加它是因为我担心一些可能导致不刷新的缓存问题......除了我的 url,你还看到其他什么不会允许在正文部分运行它吗?
【解决方案2】:

查看这个网址:-

http://davidwalsh.name/automatically-refresh-page-javascript-meta-tags

http://www.techtricky.com/how-to-refresh-page-or-part-of-the-page-automatically/

试试这个

JavaScript 方法

var timer = null;
function auto_reload()
{
  window.location = 'http://domain.com/page.php';
}

 <body onload="timer = setTimeout('auto_reload()',10000);">

元标记方法

以下内容每 30 秒刷新一次页面。

<head>
<meta http-equiv="refresh" content="30" />
</head>

<meta http-equiv="refresh" content="0;http://www.example.com" />

或者

<meta http-equiv="refresh" content="0;URL=http://www.example.com" />

或者

<meta http-equiv="refresh" content="30;URL=http://intranet/page.asp?x=123" />

【讨论】:

  • 嗨,我试过了,它和我以前的一样工作得很好。我只是不知道为什么有时它不会刷新。有没有其他方法可以在 X 秒后重新加载页面?
  • 我在回答上面添加了一些新的解决方案看看
  • 感谢您迄今为止的帮助。我不知道重置的秒数,直到后来在体内。我有查询要运行等,然后我会知道页面必须重新加载的秒数。
猜你喜欢
  • 1970-01-01
  • 2013-01-25
  • 2012-01-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多