Aktualisiert Antwort von @omar-fernando-pessoa, um mit Bootstrap 3.4.1 zu arbeiten
https://jsbin.com/monupudode/1/edit?html,output
JS Bin (function() { var proxied = window.alert; window.alert = function() { modal = $('<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button><h4 id="myModalTitle" class="modal-title">Modal title</h4></div><div class="modal-body"><p>One fine body…</p></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button></div></div></div></div>'); modal.find(".modal-body").text(arguments[0]); modal.modal('show'); }; })(); alert('moo'); alert('cow');
Aktualisiert für Bootstrap 5.1.3
https://jsbin.com/mimexomela/1/edit?html,output
JS Bin (function() { var proxied = window.alert; window.alert = function() { modaldiv = $('<div id="myModal" class="modal" tabindex="-1" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h5 id="myModalTitle" class="modal-title">Modal title</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div><div class="modal-body"><p>Modal body text goes here.</p></div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button></div></div></div></div>'); modaldiv.find(".modal-body").text(arguments[0]); modal = new bootstrap.Modal(modaldiv); modal.show(); }; })(); alert('moo'); alert('cow');