?? windowprinter.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 + -