I-AM-OBODO Posted February 18, 2023 Share Posted February 18, 2023 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> Quote Link to comment Share on other sites More sharing options...
gizmola Posted February 21, 2023 Share Posted February 21, 2023 When you try to run on page load..... what? Typical jquery loading would be in the document ready: $(document).ready(function(){ $("#staticbackdrop").modal('show'); }); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.