Home > database >  How to auto close newsletter popup in shopify after 10-15 seconds?
How to auto close newsletter popup in shopify after 10-15 seconds?

Time:07-21

I developed a newsletter popup modal in liquid for a Shopify store. I want to make the popup close automatically after 15 seconds whether the user clicks on the close button or not.

Following is the link to my code file: https://textdoc.co/index.php/x6slY3CVRXZFUtrD
Review it live here: https://www.desire4leather.com/

CodePudding user response:

Trigger a click of .jsclosepoup after a 15 seconds timeout.

Add this javascript snippet at the end of your code file:

{% javascript %}
  function closePopup() {
    $('.jsclosepoup').click()
  }

  var closePopupDelay = 15 * 1000
  setTimeout(closePopup, closePopupDelay)
{% endjavascript %}
  • Related