document.getElementById('id').src =不从缓存重新加载 [英] document.getElementById('id').src = reload not from cache

查看:529
本文介绍了document.getElementById('id').src =不从缓存重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法从缓存中重新加载元素会遇到问题.

i´ve a problem by reload elements not from cache.

第一拳,我的头

<meta http-equiv="expires" content="0"><!-- no cache-->
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"/>
<meta http-equiv="content-script-type" content="text/javascript">

因此,我在.php编写和更改的外部.txt文档中使用了JavaScript var 我的任务是将该变体实现为HTML,并每10秒保持它们不变. 我使用了以下代码:

So I´ve JavaScript var in external .txt documents written and changed by .php My task is to implement this var into HTML and keep them actual every 10 sec. I used following code:

<script type="text/javascript" id="Perso_UHS_1"></script>
<script>
    function reldataperso(){
    var dper = new Date();
    document.getElementById('Perso_UHS_1').src =
        "PersonalkapazitatUHS1.txt?time" + dper.getTime();
    };
    setInterval(function(){ 
        reldataperso();
        alert("test")
     }, 10000);
</script>
</head>
<body onload="reldataperso()">

好的,这适用于.jpg或.html,但不适用于头部的.txt.浏览器不要尝试重新加载,因为警报每10秒就要来一次...

OK, this works with .jpg oder .html but not by .txt in the head. The Browser don´t try to reload, by the alert was coming every 10 seconds...

你有什么主意吗?

推荐答案

您对'cache-control'的定义有误,也许可以解决

You have the 'cache-control' one wrong defined, maybe it fixes it

<meta http-equiv='cache-control' content='no-cache'>

这篇关于document.getElementById('id').src =不从缓存重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆