时间延迟重定向? [英] time delayed redirect?

查看:143
本文介绍了时间延迟重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,它可以滑动到我的HTML中称为博客的部分。我希望用户简单地看到页面,然后重定向到我的博客引擎。

I have a website which slides to a "section" called blog in my HTML. I want the user to simply see the page for a brief second or 2 then redirect to my blog engine.

请建议延迟重定向吗?

如果我可以根据点击博客li的时间推迟重定向:

If i can redirect with a time delayed based on the click of the blog li:

<li data-target="blog" data-target-activation="click" class="tile icon_add_favourite">
          <div>
            <h2>Blog</h2><h3>13</h3>
                <script type="text/JavaScript">
                &lt;!--
                    setTimeout("location.href = 'http://www.mysite.co.uk/blog';", 1500);
                --&gt;
                </script>
          </div>
        </li>

更新:当HTML5滑动到区块时,该页面仍在渲染所有代码,因此JS应该由click事件触发,然后根据计时器运行重定向。

UPDATE: This is sooo strange when the HTML5 slides to the section block the page is still rendering with all the code and therefore the JS should be fired by the click event then run the redirect based on the timer.

这些解决方案在JS中以弹出警报框。想知道为什么他们不在我的网页上工作吗?

The solutions work in JS as the alert boxes pop up. Wonder why they dont work in my page?

推荐答案

编辑


我面临的问题是,HTML5全部位于一个索引页面上。所以我需要
计时器才能点击博客链接。

The problem i face is that HTML5 is all on one index page. So i need the timer to start on click of the blog link.

尝试在点击处理程序中调用setTimeout博客链接,

Try calling the setTimeout inside a click handler on the blog link,

$('#blogLink').click (function (e) {
   e.preventDefault(); //will stop the link href to call the blog page

   setTimeout(function () {
       window.location.href = "blog.html"; //will redirect to your blog page (an ex: blog.html)
    }, 2000); //will call the function after 2 secs.

});






尝试使用 setTimeout 函数如下,


Try using setTimeout function like below,

setTimeout(function () {
   window.location.href = "blog.html"; //will redirect to your blog page (an ex: blog.html)
}, 2000); //will call the function after 2 secs.

这篇关于时间延迟重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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