- This topic has 4 replies, 2 voices, and was last updated 1 year, 11 months ago by
sandyms. This post has been viewed 768 times
-
AuthorPosts
-
December 6, 2024 at 7:03 am #10045451
sandyms
ParticipantI cannot seem to get a popup (modal) to appear when you arrive on the page that would be a Special Offer for this client. So, anyone arriving on the home page of the site, I would like this popup to appear first.
For now, I just added the special to the first slide on the homepage slideshow even though that is not what I had in mind.
How do I create this popup and have it open immediately on the home page? Please help.
Thank you.
Template Version: 10.2.0December 6, 2024 at 10:50 pm #10045453Support
KeymasterHi,
There are 2 types of lightbox/modal that you can show on page load.
1) OPTION 1
Lightbox with only an IMG for the content, example:
The POPUP HTML you put right after opening the BODY tag or at the bottom before closing it.
<div id="test-modal" class="white-popup-block p-0 mfp-hide"> <img src="https://placehold.co/600x400" class="img-fluid" /> </div>
2) JS (js/custom.js)
$(function () { $('.popup-modal').magnificPopup({ type: 'inline', preloader: false }); }); $(document).ready(function () { if ($('#test-modal').length) { $.magnificPopup.open({ items: { src: '#test-modal' }, type: 'inline' }); } });2) OPTION 2
HTML:
<button class="d-none" data-bs-toggle="modal" data-bs-target="#defaultModal" id="openModal"> Launch Default Modal </button> <div class="modal fade" id="defaultModal" tabindex="-1" role="dialog" aria-labelledby="defaultModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" id="defaultModalLabel">Default Modal Title</h4> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-hidden="true">×</button> </div> <div class="modal-body"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pellentesque neque eget diam posuere porta. Quisque ut nulla at nunc <a href="#">vehicula</a> lacinia. Proin adipiscing porta tellus, ut feugiat nibh adipiscing sit amet. In eu justo a felis faucibus ornare vel id metus. Vestibulum ante ipsum primis in faucibus.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pellentesque neque eget diam posuere porta. Quisque ut nulla at nunc <a href="#">vehicula</a> lacinia. Proin adipiscing porta tellus, ut feugiat nibh adipiscing sit amet. In eu justo a felis faucibus ornare vel id metus. Vestibulum ante ipsum primis in faucibus.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button> </div> </div> </div> </div>
JS:
$(window).on('load', function(){ var delay = 300; // Time in mili-seconds setTimeout(function(){ $('#openModal').trigger('click'); }, delay); });* Use only one of them.
Kind Regards.
December 7, 2024 at 7:58 am #10045455sandyms
ParticipantThis reply has been marked as private.December 7, 2024 at 11:20 pm #10045456Support
KeymasterThis reply has been marked as private.December 8, 2024 at 3:28 am #10045457sandyms
ParticipantYes! That worked and thank you very much for this!
You always go above and beyond to help and it is greatly appreciated. 🙂
-
AuthorPosts
This topic is marked as "RESOLVED" and can not rceive new replies.