Sol
Sol

Reputation: 1029

How to delay a JQuery window reload?

What am I missing? I can't seem to delay this even though the syntax seems correct.

window.location.reload(true).delay(800);//true= hard refresh

Upvotes: 1

Views: 2035

Answers (1)

Paul Roub
Paul Roub

Reputation: 36438

reload() doesn't return anything that I know of; certainly not a jQuery object, or any object on which delay() could be called.

Not that it matters - reload() takes effect immediately.

You want to use setTimeout() to delay the actual call to reload()

setTimeout( 
  function() {
    window.location.reload(true);
  }, 800);

Upvotes: 2

Related Questions