Solution 1 :

Check if this what you are looking for. I reduced the interval

If the modal is already popped you do not need to worry about the timer.

setInterval( () => {
	$("#myModal").modal();
}, 10000);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>

<!-- jQuery Modal -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css" />

<div id="myModal" class="modal">
  <p>A Modal dialog</p>
  <a href="#" rel="modal:close">Close</a>
</div>

<!-- Link to open the modal -->
<p><a href="#myModal" rel="modal:open">Open Modal Manually</a></p>

Solution 2 :

Your code clears the interval if run for more than 30 seconds.

Remove the line with clearInterval, and it won’t stop:

var count=-1; 
var counter=setInterval(timer, 1000); 
function timer() 
{
  count=count+1;
  if (count >=30) 
  {
      $("#myModal").modal();
  }
    document.getElementById("timer").innerHTML=count + " secs"; // watch for spelling
}

Problem :

I want my popup to appear every 30 seconds on my website.
and the pop will appear every 30 seconds onwards.
Now I only have javascript like this :

var count=-1; 
var counter=setInterval(timer, 1000); 
function timer()
{
  count=count+1;
  if (count >=30) 
  {
     clearInterval(counter);

      $("#myModal").modal();
     return;
  }
    document.getElementById("timer").innerHTML=count + " secs"; // watch for spelling
}

Thanks

Comments

Comment posted by How to Ask

Welcome to StackOverflow! As a courtesy tip: your post title appears to be in another language. On SO questions are expected to be asked in English– you are also much more likely to get community interest if they can understand the post from the title in the expected language. Furthermore, your post states what the desired behavior is but not the problem you are encountering. It might help to review

Comment posted by Supun De Silva

Also it is

By