Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

time delayed redirect?

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.

Please suggest a time delayed redirect?

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> 

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.

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

like image 794
SOLDIER-OF-FORTUNE Avatar asked Mar 26 '12 18:03

SOLDIER-OF-FORTUNE


People also ask

How do I redirect after 5 seconds?

To redirect a webpage after 5 seconds, use the setInterval() method to set the time interval. Add the webpage in window. location. href object.

How do I redirect a certain time?

To redirect from an HTML page, use the META Tag. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The value of the content is the number of seconds; you want the page to redirect after.

How do you delay a href?

To delay a link with inline javascript, just set your href attribute as href="javascript:setTimeout(()=>{window. location = 'URL' },500);" . When you replace the URL with your link, just make sure it is inside the ' ' .

What is delay () in Javascript?

Conclusion. setTimeout() is a method that will execute a piece of code after the timer has finished running. let timeoutID = setTimeout(function, delay in milliseconds, argument1, argument2,...); The delay is set in milliseconds and 1,000 milliseconds equals 1 second.


1 Answers

Edit:

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.

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.  }); 

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. 
like image 78
Selvakumar Arumugam Avatar answered Oct 22 '22 19:10

Selvakumar Arumugam