akaayy
V2EX  ›  问与答

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

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