akaayy
V2EX  ›  问与答

可以用 js 来实现每天的上午 8 点定时刷新本页面吗?

  •  
  •   akaayy · Oct 1, 2015 · 4437 views
    This topic created in 3889 days ago, the information mentioned may be changed or developed.
    比如设置一个 24 小时的倒计时,结束的时候刷新一下本页。
    这个方案是否可靠? js 能活那么长时间吗?

    我就想每天 8 点刷新一下一个页面,除了这个,还有什么可靠方案?


    例如
    <head><meta http-equiv="refresh" content="86400"></head>

    或者
    window.setTimeout("window.location='index.shtml'",86400*1000);
    12 replies    2015-10-02 03:56:25 +08:00
    jjplay
        1
    jjplay  
       Oct 1, 2015
    感觉没啥问题,估计会有秒数的差距
    wolfan
        2
    wolfan  
       Oct 1, 2015
    那也要开着 Web 才可以吧?
    kchum
        3
    kchum  
       Oct 1, 2015
    你开着电脑浏览器,就为这么一刷?
    yeyeye
        4
    yeyeye  
       Oct 1, 2015
    setTimeout 每秒检测一次当前时间,然后做判断
    LWXYFER
        5
    LWXYFER  
       Oct 1, 2015
    上面大家问过了,你要一直开着浏览器吗?
    abcdabcd987
        6
    abcdabcd987  
       Oct 1, 2015
    如果只是访问网站,不要求执行 js 的话,用 cron + curl 就行了呀
    dong3580
        7
    dong3580  
       Oct 1, 2015 via Android
    websocket 推送给前端,后端没 24 小时推送一次。
    heaton_nobu
        8
    heaton_nobu  
       Oct 1, 2015
    js 是在客户端运行的
    shsf4
        9
    shsf4  
       Oct 1, 2015
    js 获取当前时间,如果是 8 点的话刷新
    wibile
        10
    wibile  
       Oct 1, 2015
    selenium 啊,随便写个脚本就成。。。
    likuku
        11
    likuku  
       Oct 1, 2015
    ifttt 可以么?
    nikoukou
        12
    nikoukou  
       Oct 2, 2015
    casper.js+crontab could fullfill your requirement.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1157 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 17:49 · PVG 01:49 · LAX 10:49 · JFK 13:49
    ♥ Do have faith in what you're doing.