dialog.js

来自「自己写的一个网络日志(BLOG)系统」· JavaScript 代码 · 共 42 行

JS
42
字号
function getAbsolutePos(el) {	var r = { x: el.offsetLeft, y: el.offsetTop };	if (el.offsetParent) {		var tmp = getAbsolutePos(el.offsetParent);		r.x += tmp.x;		r.y += tmp.y;	}	return r;};function __dlg_onclose() {	opener.Dialog._return(null);};function __dlg_init(bottom) {	var body = document.body;	var body_height = 0;	if (typeof bottom == "undefined") {		var div = document.createElement("div");		body.appendChild(div);		var pos = getAbsolutePos(div);		body_height = pos.y;	} else {		var pos = getAbsolutePos(bottom);		body_height = pos.y + bottom.offsetHeight;	}	window.dialogArguments = opener.Dialog._arguments;	if (!document.all) {		window.sizeToContent();		window.sizeToContent();		window.addEventListener("unload", __dlg_onclose, true);		window.innerWidth = body.offsetWidth;		window.innerHeight = body_height;	} else {		window.resizeTo(body.offsetWidth, body_height);		var ch = body.clientHeight;		var cw = body.clientWidth;		window.resizeBy(body.offsetWidth - cw, body_height - ch);	}};function __dlg_close(val) {	opener.Dialog._return(val);	window.close();};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?