-5

I want to add a delay time for an href

 href = {{ page( ) }}

I want to add a delay time before redirecting to the next page .

Option
  • 2,605
  • 2
  • 19
  • 29
  • It's not task for PHP/Laravel, but JS. You're looking for `setTimeout`. – pavel Nov 06 '17 at 12:15
  • yes , i want to use setTimeout but i don't know the good syntax to use it on laravel . – infocrasher Nov 06 '17 at 12:16
  • Nothing to do with laravel. Study basics of JS syntax. In HTML you need to work with `onclick` attribute instead of `href`. – pavel Nov 06 '17 at 12:18
  • see this [setTimeout](https://www.w3schools.com/jsref/met_win_settimeout.asp) and make it on [href click](https://stackoverflow.com/questions/14867558/html-tag-a-want-to-add-both-href-and-onclick-working) – M0ns1f Nov 06 '17 at 12:20

1 Answers1

3

There is no option for it in Laravel. You can do it with JS:

<a id="theLink" href = {{ page( ) }}>LINK</a>


<script>
  $('#theLink').on('click', function(e) {
      e.preventDefault();
      var self = this;
      setTimeout(function() {
          window.location.href = self.href;
      }, 2000);
  });

Lexxusss
  • 542
  • 4
  • 10