JavaScript (HTML5): ブラウザを開く

snippet-windowopen

JavaScript: snippet-windowopen.js

(function(){
	function SnippetWindowOpen(href) {
		this.href = href;
	};
	SnippetWindowOpen.prototype.open = function() {
		window.open(this.href, "snippets", "width=320px, height=320px;");
	};
	function loaded() {
		this.snippet = new SnippetWindowOpen("http://snippets.feb19.jp");
		
		// button
		var button = document.createElement("input");
		button.type = "button";
		button.value = "open";
		document.body.appendChild(button);
		var that = this;
		button.onclick = function() {
			
			// ここで画面を開く
			that.snippet.open();
		}
	};
	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);