ModalWindow Examples

Simple script to replace javascript build in prompt, confirm and alert.

View ModalWindow.js

Prompt

var myPrompt = {
	type: "prompt",
	title: "My Prompt",
	text: "Hello world!",
	yes_button: "Yes",
	cancel_button: "Cancel",
	yes: function(value) {
		alert(value);		
	}
};

Demo

Confirm

var myConfirm = {
	type: "confirm",
	title: "My Confirm",
	text: "Hello world!",
	yes_button: "Yes",
	no_button: "No",
	cancel_button: "Cancel",
	yes: function() {
		alert("Yes Please");	
	},
	no: function() {
		alert("No Thanks");
	}
};

Demo

Alert

var myAlert = {
	type: "alert",
	title: "My Alert",
	text: "Hello world!",
	yes_button: "Ok",
	width: 600
};

Demo

Options

type - alert, confirm, prompt

opacity - opacity of overlay default is "0.5"

width - width of popup, default is quater width of window

height - height of popup, default is auto

title - title that appears in popup, default is "Popup"

text - text that appears in popup window

yes_button - yes button text, defaults to "yes"

no_button - no button text, defaults to "no"

cancel_button - cancel button text, defaults to "cancel"

yes - yes callback function, defaults to null

no - no callback function, defaults to null