Abdullah Noor
Abdullah Noor

Reputation: 46

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

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/

Upvotes: 1

Views: 400

Answers (1)

Jimmy
Jimmy

Reputation: 2831

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 %}

Upvotes: 2

Related Questions