Modal Boxes by Andrew Rodebaugh

By Andrew Rodebaugh on Aug 29, 2015


Modal Dialogs the easy custom way!


Alerts are ugly what I made was a script to customize Dialogs with css. All you need to do is use this code modaljs(title,body); and customize with the docs at!

Code Snippet

//Modal.js is by Cosmic Open Source Projects v0.2

//How it works?

//1. Saves your old code!
//2. Adds a script to the end and adds your prefrences to it!
//3. Redirects to it!

modaljs = function(title,body) {

  var was = document.body.innerHTML;

  document.body.innerHTML = was + "<div id='openModal' class='modal'><div><a href='#close' title='Close' class='close'>X</a><h2>" + title + "</h2><p>" + body + "</p></div></div>";
  window.location = "#openModal";