Modal Boxes by Andrew Rodebaugh | JavaScriptSource

Modal Boxes by Andrew Rodebaugh

Andrew Rodebaugh Aug 29, 2015

Abstract

Modal Dialogs the easy custom way!

Description

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 http://bit.ly/1N1Wj7j!

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";

}

Leave a Response

(0 comments)