www.gusucode.com > 较早时候的js仿windows窗口特效源码程序 > 较早时候的js仿windows窗口特效/mWindow/mWindow/JS/oc_mWindow.js

    // JavaScript Document for oc_mWindow functions
var oc_mWindow = {
	width: 300,			//init width of mWindow
	height: 143,			//init height of mWindow
	title: " ",		//init alert title
	content: " ",		//init alert content
	//Download by http://www.srcfans.com
	init: ocMWinInit,		//main function to create all htmls
	setTitle: setOcWinTitle,	//function to set alert title
	setSize: setOcWinSize,		//function to set mWindow size
	setBgSize: setOcWinBgSize,	//function to set mWindow background size
	setCenter: setOcWinCenter,	//function to make sure the mWindow in the page center and middle

	alert: ocWinAlert,		//main function like alert() in javascript
	resize: ocWinOnresize,		//function to resize background of mWindow
	show: showOcWin,		//function to show mWindow
	hide: closeOcWin		//function to close mWindow
}

function setOcWinSize(width, height){
	if(!isNaN(width)){	//(width.toString()).indexOf("px") == -1
		oc_mWindow.width = width;
		oc_mWindow.height = height + 23;

		var headWidth = (width - 4) + "px";
		var titleWidth = (width - 6) + "px";
		var bodyWidth = (width - 6) + "px";
		var confirmWidth = (width - 6) + "px";
		var footWidth = (width - 2) + "px";

		width += "px";
		height += "px";
	}else{
		width = width.replace("px","");
		height = height.replace("px","");

		oc_mWindow.width = width;
		oc_mWindow.height = height + 23;

		var headWidth = (width - 4) + "px";
		var titleWidth = (width - 6) + "px";
		var bodyWidth = (width - 6) + "px";
		var confirmWidth = (width - 6) + "px";
		var footWidth = (width - 2) + "px";

		width += "px";
		height += "px";
	}

	setWidth("oc_mWindow", width);
	setWidth("oc_mWindow_head", headWidth);
	setWidth("oc_mWindow_title", titleWidth);
	setWidth("oc_mWindow_body", bodyWidth);
	setWidth("oc_mWindow_confirm", confirmWidth);
	setWidth("oc_mWindow_foot", footWidth);

	setHeight("oc_mWindow_body_left", height);
	setHeight("oc_mWindow_body", height);
	setHeight("oc_mWindow_body_right", height);
}

function setOcWinBgSize(){
	var width = pageWidth() + "px",
	    height = pageHeight() + "px";

	setWidth("oc_mWindow_bg", width);
	setHeight("oc_mWindow_bg", height);
	setLeft("oc_mWindow_bg", 0);
	setTop("oc_mWindow_bg", 0);
}

function setOcWinCenter(){
	var left = 0,
	    top = 0;

	left = (pageWidth() - oc_mWindow.width)/2 + "px";
	top = (pageHeight() - oc_mWindow.height)/2 + "px";

	setLeft("oc_mWindow", left);
	setTop("oc_mWindow", top);
}

function ocWinOnresize(){
	setOcWinCenter();
	setOcWinBgSize();
}

function showOcWin(){
	setOcWinCenter();
	setOcWinBgSize();
	show("oc_mWindow_bg");
	show("oc_mWindow");
}

function closeOcWin(){
	oc_mWindow.width = $w("oc_mWindow");
	oc_mWindow.height = $h("oc_mWindow");
	hide("oc_mWindow");
	hide("oc_mWindow_bg");
}

function setOcWinTitle(value){
	$("oc_mWindow_title_text").innerHTML = value;
}

function ocWinAlert(text){
	$("oc_mWindow_alert").innerHTML = text;
	oc_mWindow.show();
}

function ocMWinInit(){
	var html = "<!--oc_mWindow start-->"
		 + "<div id=\"oc_mWindow\">"
		 + "  <div id=\"oc_mWindow_head_left\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"
		 + "  <div id=\"oc_mWindow_head\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"
		 + "  <div id=\"oc_mWindow_head_right\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"

		 + "  <div id=\"oc_mWindow_title_left\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"
		 + "  <div id=\"oc_mWindow_title\">"
		 + "    <div id=\"oc_mWindow_title_text\">" + oc_mWindow.title + "</div>"
		 + "    <div id=\"oc_mWindow_title_close\"><img src=\"Images/gif/关闭按钮.gif\" border=\"0\" onclick=\"closeOcWin()\" /></div>"
		 + "  </div>"
		 + "  <div id=\"oc_mWindow_title_right\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"

		 + "  <div id=\"oc_mWindow_body_left\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"
		 + "  <div id=\"oc_mWindow_body\">"
		 + "<div id=\"oc_mWindow_alert\">" + oc_mWindow.content + "</div>"
		 //+ "    <!--iframe width=\"100%\" height=\"100%\" frameborder=\"0\" src=\"http://www.oncecode.com\"></iframe-->"
		 //change the alert mWindow to a frame window
		 + "  </div>"
		 + "  <div id=\"oc_mWindow_body_right\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"

		 + "  <div id=\"oc_mWindow_confirm_left\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"
		 + "  <div id=\"oc_mWindow_confirm\">"
		 + "  <img id=\"oc_mWindow_confirm_btn\" src=\"Images/gif/确定按钮.gif\" border=\"0\" onclick=\"oc_mWindow.hide()\" />"
		 + "  </div>"
		 + "  <div id=\"oc_mWindow_confirm_right\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"

		 + "  <div id=\"oc_mWindow_foot_left\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"
		 + "  <div id=\"oc_mWindow_foot\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"
		 + "  <div id=\"oc_mWindow_foot_right\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"
		 + "</div>"
		 + "<!--oc_mWindow end-->"

		 + "<!--oc_mWindow background start-->"
		 + "<div id=\"oc_mWindow_bg\"><img src=\"Images/gif/1_1.gif\" border=\"0\" /></div>"
		 + "<!--oc_mWindow background end-->";

	document.write(html);
}