Simplest Pure JavaScript Popup library – popup.js

Category: Javascript , Modal & Popup | April 26, 2016
Author:LisaSound
Views Total:4,150 views
Official Page:Go to website
Last Update:April 26, 2016
License:MIT

Preview:

Simplest Pure JavaScript Popup library – popup.js

Description:

popup.js is a simple, lightweight JavaScript library which lets you display any html content in a popup window without any 3rd dependencies like jQuery.

How to use it:

Import the popup.js into your html document.

<script src="popup.js"></script>

Set the title and inner content you want to display in the popup window.

var myPopup = new smq.Popup({
    title: 'Popup Window',
    innerHtml: 'Inner HTML Content'
});

Style the popup window whatever you like:

smq-popup {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.2);
  z-index: 2000;
  display: block;
}
smq-popup .window {
  margin: 200px auto;
  width: 500px;
  min-height: 100px;
  background: rgba(255,255,255,1);
  border-radius: 10px;
}
smq-popup .close {
  margin: 0 10px 0 0;
  float: right;
  color: rgba(200,200,200,1);
  font-size: 20px;
  cursor: pointer;
  font-family: sans-serif;
}

Show the popup window.

myPopup.show();

Close the popup window.

myPopup.close();

 

You Might Be Interested In:


2 thoughts on “Simplest Pure JavaScript Popup library – popup.js

  1. Iain Parsons

    Great modal! I had problems closing it too until I did an inspect and found the hidden “x”. I’ll css my way out of that, but that little faint “x” is hard to see out of the box!

    Reply

Leave a Reply