⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windowprinter.js

📁 JSVM核心类库,收集了JAVA进行JSVM开发必用技术进行归纳,在实际项目应用中直接引用相关类库即可现实JSVM相关功能!
💻 JS
字号:
// Description: js.io.WindowPrinter Window 输出类
// Author:	Changhua.Wan
// Version:	2004.03.06.01

_package("js.io");
_import("js.io.OutputStream");

function js.io.WindowPrinter() {

	this.write = function(_obj) {
		this.openStream();
		_printWindowHandle.print(_obj);	
	};
	this.writeln = function(_obj) {
		this.openStream();
		_printWindowHandle.println(_obj);
	};
	this.active = false;
	var _printWindowHandle = null;
	this.openStream = function() {
		if (_printWindowHandle == null || _printWindowHandle.closed) {
			_printWindowHandle = window.open('about:blank',
								'',
								'top=100,left=100,width=320,height=320,resizable=yes'
							);
			_printWindowHandle.document.open();
			_printWindowHandle.document.write(
				  '<html><head><title>'
				+ this.className
				+ ' Window</title>'
				+ '<script>'
				+ 'var owner=null;'
				+ 'function print(s){document.body.insertAdjacentHTML("BeforeEnd",s);}'
				+ 'function println(s){print(s+"<br/>");}'
				+ 'function clear(){document.body.innerHTML="";}'
				+ '</script>'
				+ '<script>window.onunload = function(){owner.closeStream();}</script>'
				+ '</head><body style="font-size:9pt;border:1 inset;" scroll="auto" designMode="on" contentEditable="true"></body></html>'
				);
			_printWindowHandle.document.close();
			_printWindowHandle.owner = this;
		}
		_printWindowHandle.focus();
		this.active = true;
	};
	this.closeStream = function() {
		if (_printWindowHandle != null && !(_printWindowHandle.closed)) _printWindowHandle.close();
		_printWindowHandle = null;
		this.active = false;
	};
	this.print = function(_s) {
		this.write(_s);	
	};
	this.println = function(_s) {
		this.writeln(_s);	
	};
	this.printError = function(ex) {
		var _s = "<font color=red>" + ex.toString() + "</font>";
		this.println(_s);
	};
	this.printObject = function(obj) {
		if (typeof(obj) != "object") {
			this.println(String(obj));
		} else {
			if (Class.instanceOf(obj,"Error") || Class.instanceOf(obj,"js.lang.Exception"))
				this.printError(obj);
			else
				this.println(obj);
		}
	};
	this.printText = function(s) {
		this.print("<XMP>" + s + "</XMP>");
	}
	this.clear = function() {
		if (_printWindowHandle != null && !(_printWindowHandle.closed))
			_printWindowHandle.clear();
	}
}
var _p = js.io.WindowPrinter._extends("js.io.OutputStream");

⌨️ 快捷键说明

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