I want to display popup using fancybox when page load in magento2 . How is it possible ?
Please help me….
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
require([ 'jquery', 'jquery/ui','fancybox'], function( $ ) {
$(document).ready(function() {
$.fancybox("#hidden");
//alert("a");
});
});
</script>
</head>
<body>
<div id="hidden" style="display:none;">
Hi this is hidden
</div>
</body>
</html>
Best Answer
For Exmaple: I used magnify popup to display popup on load page
1) First of all put js and css files of your popup in web folder of module
2) Now define your custom popup js in requirejs-config.js or create new requirejs-config.js file
3) Now create template file for popup
4) Inject this template file in xml where you need to show popup
for exmaple to show popup on home page. ovveride cms_index_index.xml