Yes, it's possible to display content in a lightbox on CMS pages in Magento 2 without calling an external JS script. Here's how you can achieve this:
Add the required HTML markup to your CMS page as follows:
<div class="popup-link">Click here</div>
<div class="popup-content" style="display:none;">
Some content to go here...
Some content to go here...
Some content to go here...
Some content to go here...
Some content to go here...
<div class="close-popup">Close</div>
</div>
Add the following JavaScript code to the end of your CMS page content:
<script type="text/javascript">
require(['jquery', 'Magento_Ui/js/modal/modal'], function($, modal) {
var options = {
type: 'popup',
responsive: true,
innerScroll: true,
title: '',
buttons: []
};
var popup = modal(options, $('#popup-modal'));
$(".popup-link").on('click',function(){
$("#popup-modal").modal("openModal");
});
});
Save your CMS page.
This code uses Magento 2's built-in modal functionality to display the content in a lightbox when the user clicks on the "Click here" link. The "popup-link" class is used to target the link, and the "popup-content" class is used to target the content that will be displayed in the lightbox. The "close-popup" class is used to target the close button inside the lightbox. The JavaScript code initializes the modal with the required options and opens it when the user clicks on the link.
Note: Make sure that you have included the jQuery library on your CMS page before the JavaScript code, as it's required for the modal to work.