How do I make a Modal popup appear upon entry to the website without having to press a button or link.
I use the Cadence bric.
Unfortunately it’s not available on the Blocs Store any more.
You can create a modal, give it an ID, example modal-49911, then add a code bric. Add this code to the footer section in the code bric. Obviously replace the part with modal-49911 with what ID you gave your modal.
<script>
document.addEventListener("DOMContentLoaded", function() {
var myModal = new bootstrap.Modal(document.getElementById('modal-49911'));
myModal.show();
});
</script>
Not sure if this is best practise but it works.
2 Likes
Although that works, I would incorporate some Session Storage to set a flag, so when a user closes the modal, they then do not see it every time they load a page. Unless thats your intention,
3 Likes
Actually implemented exactly this on my website today
3 Likes
Nice… a good user experience… and a good deal for users too $$
If you haven’t already… collect the set from @Jannis
1 Like