JavaScript (HTML5): ダイアログの表示

snippet-alert

(function(){
	function SnippetAlert() {
		var button = document.createElement("input");
		button.type = "button";
		button.value = "alert";
		document.body.appendChild(button);
		var that = this;
		button.onclick = function() {
			that.showAlert();
		};
	};
	SnippetAlert.prototype.showAlert = function() {
		if (window.confirm("Hello World.")) {
			console.log("OK");
		} else {
			cansole.log("Cancel");
		}
	};
	function loaded() {
		window.snippet = new SnippetAlert();
	};
	if(document.addEventListener){
		document.addEventListener("DOMContentLoaded", loaded, false);
	} else if(/msie/.test(navigator.userAgent.toLowerCase())){
		try {
			document.documentElement.doScroll("left");
		} catch(error){
			setTimeout(arguments.callee, 0);
			return;
		}
		loaded();
	}
}).call(this);