
Simple Popup is a native JavaScript library for creating responsive and always centered popup windows on your page. You can also use it as a jQuery library or as an AMD/CommonJS module.
How to use it:
Download and include the simple-popup.js JS library in your document.
<script src="simple-popup.js"></script>
Create a button to launch a popup window.
<button type="button" id="open">Open</button>
Embed your content into the popup window following the markup structure like so:
<div id="popup" class="popup-wrapper hide">
<div class="popup-content">
<div class="popup-title">
<button type="button" class="popup-close">×</button>
<h3>Popup Title</h3>
</div>
<div class="popup-body">
<p>Popup body</p>
</div>
</div>
</div>The JavaScript to enable the popup window & trigger button.
var popupEl = document.getElementById('popup');
// As a native plugin
var popup = new Popup(popupEl, {
width: 400,
height: 300
});
// As a jQuery plugin
// var popup = $('#popup').popup({
// width: 400,
// height: 300
// });
var open = document.getElementById('open');
open.onclick = function() {
popup.open();
};Style the popup window whatever you like:
.popup-wrapper {
background-color: #fff;
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 0 2px 8px #aaa;
overflow: hidden;
}
.popup-title {
padding: 10px 15px;
background-color: #f4f4f4;
border-bottom: 1px solid #f0f0f0;
}
.popup-title h3 {
margin: 0;
line-height: 1.5em;
color: #333;
}
.popup-body {
padding: 10px 15px;
color: #555;
}
.popup-close {
float: right;
margin-top: 2px;
padding: 0;
font-size: 24px;
line-height: 1;
border: 0;
background: transparent;
color: #aaa;
cursor: pointer;
}
.popup-close:hover { color: #333; }Default options.
width: 500, height: 400, offsetX: 0, offsetY: 0, zIndex: 999, closeBtnClass: 'popup-close'
The method to close the popup window.
popup.close();







I did the same but I’m receiving the error “Popup is not defined(…)” even when I’m loading the script, any help?