picoModal accessible and crossbrowser
A small, self-contained JavaScript modal library, without jQuery or another third party script, for IE8+ and all modern browsers, and accessible.
Original idea from https://github.com/Nycto/PicoModal
You can pass the HTML content of the modal as unique argument:
picoModal("<h1>Example</h1><p>This is a simple example for picoModal. We can write something longuer or shorter or we can use Lorem Ipsum that is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>")
You can also use some arguments:
var modal = picoModal({
content:"<h1>Example</h1><p>This is a simple example for picoModal.</p>"
});
modal.onClose(function() { alert("Closed") });
Change overlay style (or you can use CSS by styling .pico-overlay):
picoModal({
content:"<h1>Example</h1><p>This is a simple example for picoModal.</p>",
overlayStyles:{
backgroundColor: "#169",
opacity: 0.75
}
})
To disable the close button and overlay close, and give focus on the h1 (for screen-readers):
_modal = picoModal({
content:'<h1 id="pico_title">Example</h1><p>This is a simple example for picoModal.<br><button onclick="_modal.close()">Close me</button></p>',
closeButton:false,
overlayClose:false,
focusOn:"#pico_title"
})
The following settings are available:
The following properties are available on the object returned by picoModal: