Home > Software design >  I want to make a link unclickable for the first 10 seconds and then make it clickable
I want to make a link unclickable for the first 10 seconds and then make it clickable

Time:09-03

On my website I want to make a link unclickable for the first 10 seconds after the page loads and then make it clickable like a normal link after.

How can I achieve this?

CodePudding user response:

  1. Create CSS class with .disabled and add set it to link.
  2. In onl oad event, use setTimeout to remove the class "disabled" and set the time to 10sec.

window.onload = function (e) {
  setTimeout(() => {
    document.querySelector(".disabled").classList.remove("disabled");
  }, 10000);
};
.disabled {
  pointer-events: none;
}
<!DOCTYPE html>
<html>
  <body>
    <a href="https://google.com" >Google</a>
  </body>
</html>

  • Related