Navigation

    云、贵、川、渝IT人的圈子
    • Register
    • Login
    • Search
    • 主页
    • 问答
    • 话题
    • 热门
    • 圈子
    • 招聘
    • 活动
    • 项目

    location.href 在 setTimeout 里面失效

    技术答疑
    2
    2
    83
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • diepao172
      diepao172 last edited by

      // 这样可以
       location.href = './news/details.html?page=activity&id=' + item.id
      
      // 这样就不行,为什么?
      setTimeout(function() {
              location.href = './news/details.html?page=activity&id=' + item.id
       }, 600)
      
      1 Reply Last reply Reply Quote 0
      • liazei33
        liazei33 last edited by

        我测试过是成功的,你看看你的这个js的代码是不是绑定在一个a标签上,如果绑定在a标签上的话,你加了延迟,代码会优先执行a标签上的链接,所以你看不到定时器里面的跳转效果

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        社
        8
        玻
        U
        A
        大
        A
        黑
        低
        天
        白
        快
        爱
        白
        美
        此
        荒
        为
        哭
        柳
        无

        社群
        昆明网页设计交流吧
        友情链接
        • Funtask
        • Funtask 社区
        • SUWIS
        • 云南北大青鸟
        ©2019-2020 滇ICP备20006698号