Jump to content

Run at pageload


I-AM-OBODO

Recommended Posts

Hi, I am trying to get this bootstrap modal to run on page load. It works fine on button click but i want it to run on page load

thanks

<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="staticBackdropLabel">Downloading...</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
       <div class="progress" style="height: 30px;">
          <div id="myBar" class="progress-bar progress-bar-striped bg-success progress-bar-animated" role="progressbar" style="width: 0%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">50%</div>
        </div>
        <p id="myP" class="p-3">Downloading: <span id="demo">0</span></p>
      </div>
      <div class="modal-footer">
        <!-- <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> -->
        <button type="button" class="btn btn-secondary" onclick="location.href='start-download'">Close</button>
        
      </div>
    </div>
  </div>
</div>

<script>
  $(window).on('load', function() {
    $('#staticBackdrop').modal('show');
	function move() {
  	var elem = document.getElementById("myBar");   
  	var width = 0;
  	var id = setInterval(frame, 50);
	function frame() {
    if (width >= 100) {
      clearInterval(id);
      document.getElementById("myP").className = "text-danger p-3 text-center";
      document.getElementById("myP").innerHTML = "Successfully uploaded 10 photos!";
    } else {
      width++; 
      elem.style.width = width + '%'; 
      elem.innerHTML = width * 1  + '%';
      var num = width * 1 / 1;
      num = num.toFixed(0);
      document.getElementById("demo").innerHTML = num;
    }
  }
}

});
</script>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.