【问题标题】:open external link without interrupting meta auto refresh在不中断元自动刷新的情况下打开外部链接
【发布时间】:2017-03-28 00:57:49
【问题描述】:

我有一个非常基本的 teampeak 查看器网站,可以显示当前谁在上。

我正在使用这个自动刷新标签:

<meta http-equiv="refresh" content="60;url=index.html">

我有一个连接到被点击的 Teamspeak 服务器的按钮:

<a href="ts3server://server.address?port=9999" class="ui-btn ui-corner-all ui-shadow">Connect To This TeamSpeak</a>

一切都很好,除了当我单击打开 Windows 应用程序的按钮时,互联网页面每 60 秒停止刷新一次。

我对这一切都很陌生,任何帮助将不胜感激!

【问题讨论】:

    标签: javascript html refresh


    【解决方案1】:

    尝试将target="_blank" 添加到按钮的代码中,这将使它在新选项卡中打开链接,然后转移到 Teamspeak 应用程序。这应该可以防止它对自动刷新产生任何干扰。

    【讨论】:

    • 谢谢,这行得通,除了在原始页面上留下一个空白标签。
    • 修复链接并让新标签自动关闭是相当先进的,所以希望这个解决方案是合适的。您可以尝试使用 JavaScript 刷新页面,但不保证可以正常工作,因为 TS3 链接可能会冻结整个选项卡。
    【解决方案2】:

    好的,我想通了。我删除了 html 元数据:

    <meta http-equiv="refresh" content="60;url=index.html">
    

    并修改了我从 Philip M. 2010 找到的 Javascript 代码:

    <script type = "text/javascript">
    /*author Philip M. 2010*/
    
    var timeInSecs;
    var ticker;
    
    function startTimer(secs){
    timeInSecs = parseInt(secs)-1;
    ticker = setInterval("tick()",1000);   // every second
    }
    
    function tick() {
    var secs = timeInSecs;
    if (secs <5 ) {
    document.getElementById("countdown").style.color = "red";  // and any other styling desired
    }
    if (secs>0) {
    timeInSecs--;
    }
    else {
    document.location.reload(true)
    //clearInterval(ticker); // stop counting at zero
    // startTimer(60);  // remove forward slashes in front of startTimer to repeat if required
    }
    
    document.getElementById("countdown").innerHTML = secs;
    }
    
    startTimer(60);  // 60 seconds 
    
    </script>
    
    <span id="countdown" style="font-weight: bold;">60</span>
    

    我修改的部分是:

    else {
    document.location.reload(true)
    

    现在,如果我单击按钮启动外部 Windows 应用程序,页面仍将每 60 秒刷新一次。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-09
      • 1970-01-01
      • 1970-01-01
      • 2016-11-20
      • 2019-02-16
      • 2017-06-11
      • 2012-06-27
      • 1970-01-01
      相关资源
      最近更新 更多