Need a popup for the home page for a special

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #10045451
    sandyms
    Participant

    I 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.0
    #10045453
    Support
    Keymaster

    Hi,

    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">&times;</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.


    #10045455
    sandyms
    Participant
    This reply has been marked as private.
    #10045456
    Support
    Keymaster
    This reply has been marked as private.
    #10045457
    sandyms
    Participant

    Yes! That worked and thank you very much for this!

    You always go above and beyond to help and it is greatly appreciated. 🙂


Viewing 5 posts - 1 through 5 (of 5 total)

This topic is marked as "RESOLVED" and can not rceive new replies.