请教各位怎样在B/S环境下用JavaScript和Applet交互实现Web打印?

andiyang 2001-06-23 04:40:00
现在在B/S环境下用户有很多票据需要打印,就是套打,
还有很多数据要实现普通的报表打印
在Web下有什么方法解决最好??
...全文
715 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
y1g1y1 2001-06-24
  • 打赏
  • 举报
回复
我的小站.
ygyuan.go.163.com
ygyuan.3322.net

请去此地下载!
http://www.ylw.com.cn/yf/Web/testYGYIEPageset.htm
http://www.ylw.com.cn/yf/PrintView/PrintView.htm
孟子E章 2001-06-23
  • 打赏
  • 举报
回复
ScriptX printing: technical manual


April, 2001

Download this document set [Requires Microsoft Internet Explorer 5.0?/span> or later]

Contents
Overview
Introduction
Summary of examples
HTML Printing with ScriptX: what's new?
How do I use the ScriptX object?
Client-side deployment
Basic functionality: ScriptX.cab
Advanced functionality: smsx.cab
How to check whether or not the object is properly installed
Server-side deployment
Testing your print-outs
Technical support
Reference
Overview
Introduction
MeadCo's ScriptX is a non-visual downloadable ActiveX control, developed to provide absolute control over document printing operations from client and server computers running Microsoft's Internet Explorer browser. ScriptX became well know for its HTML printing capabilties following our Scripting Support for Web Page Printing?/span> publication on the MSDN website.

Part of its purpose is to ensure the consistent formatting and appearance of printed output from any local or networked printer, regardless of the printing attributes already set in that computer's browser. ScriptX applies a document author's desired attributes at the time of printing browser window or framed content, but thereafter automatically restores all default settings and makes no other permanent changes.

ScriptX 1.0 was introduced by MeadCo in 1998 as a freely distributable utility offering a limited set of print formatting functionality - the scripted control of the printing of HTML frame or window content (with or without a prompt), and the specification by script of printing parameters such as page headers, footers, margins and paper orientation.

That basic functionality is still available at no charge and is freely distributable, with peer-to-peer and low level company technical support provided in the public ScriptX Newsgroup. Features that are part of that 'free' printing subset are marked in this document as basic.

With the releases of ScriptX 5.0 and ScriptX 5.5 significantly more advanced printing functionality was introduced which is only accessible in the presence of a paid-for MeadCo publishing license?/span>.

Target platform
ScriptX has been tested on and supports Microsoft Internet Explorer versions 4.01 SP1 - 6.0 Public Preview on all Microsoft Windows Win32 OS platforms (Windows 95/95 OSR2.x/98/98SE/Me, Windows NT4 SP4+, Windows 2000, Windows XP Beta).

Product credits
ScriptX has been widely adopted and acknowledged by the Web and intranet development communities. Check out the following early references:

Web Men Talking?/span>
Scripting Support for Web Page Printing?/span>
How do I control printing from ASP??/span>
Summary of examples
Basic
Illustrates the straightforward use of the freely distributable ScriptX basic printing functionality: headers, footers, margins and paper orientation.

Advanced
Illustrates the typical use of ScriptX advanced printing functionality for which a publishing license is required.

Techie
An all-in-one technical example illustrating the most advanced use of licensed ScriptX functionality.
Feel free to investigate the source code from any of the examples and to cut & paste fragments into your own applications.

HTML Printing with ScriptX: what's new?
The introduction ScriptX 5.0 and ScriptX 5.5 extended basic printing functionality with some powerful new features which can only be deployed in the presence of a paid-for publishing license.

New in ScriptX version 5.0
Basic printing of Microsoft Officetm and Adobe Acrobattm documents hosted in frames.


Control over the printing of a document's background color and images (printBackground).

A new SetMarginMeasure method to ensure that the chosen unit of measure for margins (inches or millimeters) will be consistent across machines with different locale settings.

Facilities to select a non-default printer, paper size & source, page range & collation and number of copies to print.

A new PrintHTML method to print one or more externally-located HTML documents. PrintHTML can also be used to implement server side printing.

New in ScriptX version 5.5
Internet Explorer 5.5's new printing architecture?/span> (including Print Templates?/span>) is fully supported. Custom Print Templates can now be deployed (templateURL). Read more about MeadCo's in-depth support for Print Templates here?/span>.

Reliability and scalability. The PrintHTML(url) method can now queue and print any number of documents without compromising system performance. This is especially important for server side printing. On the client side, PrintHTML now works in the HTTP session context of the calling page (SSL is supported as well).

Precise tracking of spooler activity (IsSpooling, WaitForSpoolingComplete, onafterprint). By default, when the Internet Explorer window is closed or the page navigated away from whilst a print-out is still being spooled, the user will be prompted. The prompt can be customized or disabled (onbeforeunload).

Print settings changes (headersbasic, footersbasic, marginsbasic, paper orientationbasic, printer name, paper size, paper source, page range selection, number of copies, collation, duplex mode) once made from script now become active for Internet Explorer's native UI Print... and Page Setup... commands, as well as for the native window.print()?/span> script method, during the time that the document is displayed. Now an author doesn't need to put a [Print] button on an HTML page.

Internet Explorer's native printing UI can now be trapped and cancelled, or handled in a particular way (disableUI, onuserprint, onuserpreview, onuserpagesetup). A documdent's DHTML user interface can also be updated in response to user changes in the Page Setup and Print dialogs (onpagesetup). See the Techie printing example for an illustration of UI handling.

All changes made to print settings affect only the current document and are automatically restored upon navigation, or when the window is closed.

A redirect of raw print-out data can be made to a specified file name (printToFileName).

Batch printing of PDF and MS Office documents (BatchPrintPDF).

Backwards compatibility
The current version of ScriptX is backwards compatible and will work with all existing publishing licenses. A number of issues have been resolved since version 1.0 and 5.0, including full support for Internet Explorer versions 5.5 and 6.0.

We strongly recommend that you update your <OBJECT> elements to reference the current version 5,60,0,360 and update the ScriptX.cab or smsx.cab files on your servers.

An important compatibility issue is that ScriptX printing will now always prompt when called in the context of Internet Explorer's Internet Security Zone (check the zone icon in the browser's status bar). This is done to prevent anonymous Internet content invoking printing without a prompt (see PRB: Printing with WebBrowser from Internet Explorer Raises Print Dialog Box in Internet Explorer 5?/span>).

For the My Computer, Local Intranet and Trusted Sites Security Zones promptless printing will work. If you need promptless printing for the Internet Security Zone, you should obtain a publishing license?/span> that will bind the deployment of ScriptX to the URL addresses from which you want to serve ScriptX-enabled content.

Another important note concerns margin units of measure (inches and millimeters). By default ScriptX uses the units of measure set on the client machine. This is OK when pages are being authored for a known environment such as a small corporate intranet where all Regional Settings are identical, but in a broader environment users' Number settings are certain to vary. So an author should specify the SetMarginMeasure method with a value of either 1 (mm) or 2 (inches). ScriptX will then print to the margins specified regardless of -- and without affecting -- a user's default Regional Number Settings.
How do I use the ScriptX object?
Before reading further, please have a look at our illustrative Basic, Advanced and Techie examples of ScriptX printing to get an idea of what ScriptX can do for you.

ScriptX can be deployed either on client-side HTML or XML pages, or from server-side script.

Client-side deployment
ScriptX is deployed as a client-side ActiveX control, instantiated and scripted on an HTML or XML page as an <OBJECT> element?/span>. Download and installation is a one-time client-side event and is handled automatically by the standard Internet Explorer Component Download?/span> security schema.

The end user's system must have the "Download Signed ActiveX Controls" and "Script ActiveX control marked as safe for scripting" security settings enabled for the corresponding Security Zone. These are the default settings for the My Computer, Local Intranet, Trusted Sites and Internet Security Zones.

ScriptX is installed from one of two signed CABs: ScriptX.cab for freely-distributable 'basic' deployment or smsx.cab for fully-functional licensed use. Both are part of a download package obtainable from the ScriptX site?/span>. The appropriate CAB file should be placed on the web server and its location should be referenced by the CODEBASE?/span> attribute of the <OBJECT> tag, as shown below.

NOTE: In your own code, we recommend that you script the ScriptX <OBJECT> elements in the document's <BODY> container.

Make sure that you provide the correct relative or fully-qualified path to the CAB file and the correct version info (5,60,0,360) in your CODEBASE?/span> attributes.

Start to script the ScriptX object only when the page is fully loaded i.e. once the window.onload?/span> event has occured.

Use the defer?/span> attribute wherever possible in your scripts: <SCRIPT defer>...<SCRIPT> and avoid immediate script statements (i.e. code which is outside of any function scope). This is an under-appreciated but very useful feature which instructs the script to execute only when the whole document's DHTML content is completely parsed. This way you can be sure of accessing every element on the page.

The folowing code snippets assume that ScriptX.cab or smsx.cab exists in the same folder as the hosting page itself.

Basic functionality: ScriptX.cab
ScriptX.cab contains the same ScriptX binaries as smsx.cab but - because the 'basic' printing subset does not need to refer to a publishing license - it excludes the Security Manager component:

<object id=factory viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="ScriptX.cab#Version=5,60,0,360">
</object>
The Basic printing example illustrates the use of the ScriptX.cab.

The viewastext attribute prevents an authoring tool such as Microsoft FrontPagetm or Visual InterDevtm from running the object at design time.

NOTE: with the 'basic' subset, you can only script header, footer, page margins, paper orientation, Print and PageSetup methods and properties.

Advanced functionality: smsx.cab
smsx.cab contains both the ScriptX and the Security Manager?/span> binaries required to publish fully-functional licensed content:

<!-- MeadCo Security Manager -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=5,60,0,360">
<param name="GUID" value="{1FB3613D-2B04-11D4-A695-0000863B364E}">
<param name="Path" value="sxlic.mlf">
<param name="Revision" value="0">
</object>

<!-- MeadCo ScriptX -->
<object id=factory viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="smsx.cab#Version=5,60,0,360">
</object>
NOTE: the {1FB3613D-2B04-11D4-A695-0000863B364E} value of the GUID parameter used above identifies the MeadCo evaluation license that authors may use to experiment with Advanced printing capabilities. The license validates local filesystem (file://) and local website (http://localhost/) content for evaluation purposes only on a single development computer.

The evaluation license is periodic. It will expire in a few months and will be replaced by a new one with a different GUID, so any code depending on the evaluation license may suddenly stop working at any time.

Registered customers are issued with an unique license identifier and a digitally signed sxlic.mlf license file. See the licensing?/span> page for more details.

Check out the sources of the Advanced and Techie printing examples for a complete illustration of how to use licensed ScriptX functionality. The following JScript code snippet shows how to modify printing settings so as to print to a specific printer:

<script defer>
function SetPrintSettings() {
// -- advanced features
factory.printing.SetMarginMeasure(2) // measure margins in inches
factory.SetPageRange(false, 1, 3) // need pages from 1 to 3
factory.printing.printer = "HP DeskJet 870C"
factory.printing.copies = 2
factory.printing.collate = true
factory.printing.paperSize = "A4"
factory.printing.paperSource = "Manual feed"

// -- basic features
factory.printing.header = "This is MeadCo"
factory.printing.footer = "Advanced Printing by ScriptX"
factory.printing.portrait = false
factory.printing.leftMargin = 1.0
factory.printing.topMargin = 1.0
factory.printing.rightMargin = 1.0
factory.printing.bottomMargin = 1.0
}

function Print(frame) {
factory.printing.Print(true, frame) // print with prompt
}
</script>
A subtle JScript syntax issue may occur when setting a printer name that contains back slashes. Don't forget to double the slashes:

factory.printing.printer = "\\\\FS-LYS-01\\HP5n-759" // print to \\FS-LYS-01\HP5n-759
How to check whether or not the object is properly installed
The following technique can be applied to the use of both ScriptX.cab and smsx.cab. Upon the window.onload?/span> event, test whether or not the object?/span> property of the ScriptX or the Security Manager object returns as a valid object. The way to do that is shown in the script snippet below.

In the event that you experience any problems with automatic client-side download and installation, check out HOWTO: Find More Information About Why Code Download Failed?/span> and Description of Internet Explorer Security Zones Registry Entries?/span> as part of your troubleshooting.

<!-- MeadCo Security Manager - using the evaluation license -->
<object id="secmgr" viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=5,60,0,360">
<param name="GUID" value="{1FB3613D-2B04-11D4-A695-0000863B364E}">
<param name="Path" value="sxlic.mlf">
</object>

<!-- MeadCo ScriptX -->
<object id="factory" viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="smsx.cab#Version=5,60,0,360">
</object>

<script defer>
function window.onload() {
if ( !factory.object ) {
alert("MeadCo's ScriptX Control is not properly installed!");
navigate("scriptx-install-error.htm");
return;
}
if ( !secmgr.object ) {
alert("MeadCo's Security Manager Control is not properly installed!");
navigate("secmgr-install-error.htm");
return;
}
if ( !secmgr.validLicense ) {
alert("The MeadCo Publishing License is invalid or has been declined by the user!");
navigate("license-error.htm");
return;
}
alert("Ready to script MeadCo's ScriptX!")
}
</script>
Server-side deployment
ScriptX can be used in the context of Microsoft's Internet Information Server?/span> (IIS) to print HTML documents on the server side.

An Active Server Page (ASP) may handle an HTTP GET or POST request and print a report as part of some server-side application logic. In this case, the print-out will take place on the server side and will go to a printer which is physically attached or networked to the server. The browsing user who originated the HTTP request may not ever see the printed output nor know that printing has taken place.

A publishing license (sxlic.exe) from MeadCo is required to enable server-side printing, and both the sxlic.exe and ScriptX.exe executables should be installed (executed) on your Windows NT4 or Windows 2000 server.

NOTE: for proper operation under server-side ASP context (that is, from <% ... %> script), ScriptX needs to be run under the IIS system account (for Windows 2000, make sure Application Protection is set to Low (IIS Process) on your IIS Web Site Properties dialog | Home Directory tab | Application Protection listbox).

In addition ScriptX uses an interactive user account, so an interactive user should be logged in on the server. ScriptX uses the Internet Explorer MSHTML rendering engine (a.k.a. Trident) to print, and this last requirement is mandated by MSHTML (see PRB: COM Objects Fail to Print When Called From ASP and HOWTO: Configure Office Applications to Run Under the Interactive User Account).

Once both the publishing license and the ScriptX binaries have been installed you can use ScriptX server-side from an ASP page thus:

<%
' the object is dynamically created and destroyed
set factory = CreateObject("ScriptX.Factory")
factory.printing.PrintHTML "http://localhost/orders/order.asp?number=" & Request.Form("number")
set factory = nothing
%>
ScriptX can also be instantiated in the IIS Application scope, which can possibly result in better scaling and performance:

<OBJECT RUNAT=Server SCOPE=Application ID=factory PROGID="ScriptX.Factory"></OBJECT>

<%
' print a document from the localhost webserver
factory.printing.PrintHTML "http://localhost/orders/order.asp?number=" & Request.Form("number")
' print a document from the file system
factory.printing.PrintHTML "file://c:\log.htm?user=" & Request.Form("user")
%>
NOTE: HTML files printed by PrintHTML calls on the server-side are loaded in a separate process in a session context which is absolutely unrelated to the current user's ASP session context. In the examples above we print http://localhost/ based URLs so technically this is still the same HTTP server, but in fact any URL may be used. The only way to pass any contextual information is via the query part of the URL itself (the strings that follows the question mark).

Look again at the second example. The query part may be processed by the server that supplies the document (the first PrintHTML call) or it may be accessed as location.search?/span> from the document's DHTML script itself (the second PrintHTML call).

Testing your print-outs
The development and testing of code to produce good-looking printed reports usually takes a number of iterations. To save toner, paper, trees and our own precious time :-) we regularly use the FinePrinttm?/span> application from FinePrint Software.

FinePrinttm installs a virtual printer driver that serves as indirection layer between the printing application (Internet Explorer in our case) and a physical or networked printer. In 'bypass' mode it lets us accurately preview and repaginate ScriptX-enabled content before it is actually printed or discarded.

It's also a very handy testing device with which to diagnose printing problems. So because we are physically unable to test ScriptX with every model and version of printer and printer driver that exists in the world, we would greatly appreciate it if you would try printing to the FinePrint driver before reporting errors against ScriptX from your particular printing environment.

NOTE: Mead & Co Limited has no commercial affiliation with FinePrint Software, LLC.

Technical support
Licensees of ScriptX' advanced printing functionality are entitled to unlimited direct-to-company email support and access to new versions of the ScriptX software as-and-when issued, both at no additional charge.

All users of ScriptX are encouraged to visit the peer-to-peer ScriptX News Group from time to time to post questions, comments and suggestions.

Please send us feedback & bug reports.

Join the MeadCo ScriptX Announcement List (now more than 8,500 subscribers) to be notified on further product updates.

Please note: support and general discussion on web printing issues is not within the remit of the list, so please don't post your questions there, they will be rejected.

To subscribe to the list, please enter your email address below and click the 'Subscribe' button:




Web support links
Microsoft Internet Explorer printing and Internet Explorer Component Download support articles:
Microsoft Support Knowledge Base articles on Internet Explorer Printing?/span>

INFO: WebCast: How Does Internet Component Download Work??/span>

HOWTO: Find More Information About Why Code Download Failed?/span>

PRB: Trust Provider Warning Message Appears When You Attempt to Download Components?/span>

PROBLEM: Blank Page Is Printed in Internet Explorer 5.5?/span>

General information on Internet Explorer printing:
Scripting Support for Web Page Printing?/span>

Printing with the Internet Explorer WebBrowser Control?/span>

Beyond Print Preview: Print Customization for Internet Explorer 5.5?/span>

Print Preview 2: The Continuing Adventures of Internet Explorer 5.5 Print Customization?/span>

Print Template Reference?/span>

Style Sheets and Printing?/span>

Inside Technique : Printing Techniques?/span>

Printing Tables on Multiple Pages?/span>

INFO: Page Break Styles Supported Only with Block Elements?/span>


--------------------------------------------------------------------------------

ScriptX printing: technical reference

Unless otherwise indicated by the basic icon, the use of any property or method requires a publishing license?/span>.

Objects
factory, printing

Properties
bottomMargin, collate, copies, disableUI, duplex, footer, header, leftMargin, onafterprint, onbeforeunload, onpagesetup, onuserpagesetup, onuserprint, onuserprintpreview, pageHeight, pageWidth, paperSize, paperSource, portrait, printBackground, printer, printToFileName, rightMargin, templateURL, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop

Methods and Functions
BatchPrintPDF, DefaultPrinter, DoPrint, EnumJobs, EnumPrinters, GetJobsCount, GetMarginMeasure, IsSpooling, IsTemplateSupported, OwnQueue, PageSetup, Preview, Print, PrintHTML, PrintPDF, PrintSetup, PrintXML, SetMarginMeasure, SetPageRange, Sleep, WaitForSpoolingComplete

Objects
factory

--------------------------------------------------------------------------------

Description
Represents the ScriptX object itself on an HTML page for scripting by its id . For historical reasons, we name it factory.

For WSH or ASP (i.e. server-side) use only, create a ScriptX instance dynamically with the JScript new ActiveXObject?/span> or the VBScript CreateObject?/span>.

Note that you can not use CreateObject or new ActiveXObject to call ScriptX client-side. You should call ScriptX in all client-side cases by the id of the on-page ScriptX object.

See How do I use the ScriptX object for deployment details.

Examples
HTML page:

<object id=factory viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="ScriptX.cab#Version=5,60,0,360">
</object>
WSH?/span> script (JScript):

var factory = new ActiveXObject("ScriptX.Factory")
factory.printing.PrintHTML("http://msdn.microsoft.com/workshop/author/script/dhtmlprint.asp")
ASP page (VBScript):

<%
set factory = CreateObject("ScriptX.Factory")
factory.printing.PrintHTML "http://localhost/orders/order.asp?number=" & Request.Form("number")
set factory = nothing
%>
Properties
printing

Methods
DoPrint, PageSetup

printing

--------------------------------------------------------------------------------

Description
Represents the printing functionality of ScriptX. See HTML Printing with ScriptX for more information and examples.

Syntax
printing = factory.printing

Properties
bottomMargin, collate, copies, disableUI, duplex, footer, header, leftMargin, onafterprint, onbeforeunload, onpagesetup, onuserpagesetup, onuserprint, onuserprintpreview, pageHeight, pageWidth, paperSize, paperSource, portrait, printBackground, printer, printToFileName, rightMargin, templateURL, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop

Methods
BatchPrintPDF, DefaultPrinter, EnumJobs, EnumPrinters, GetJobsCount, GetMarginMeasure, IsSpooling, IsTemplateSupported, OwnQueue, PageSetup, Preview, Print, PrintHTML, PrintPDF, PrintSetup, PrintXML, SetMarginMeasure, SetPageRange, Sleep, WaitForSpoolingComplete

Applies To
factory

Properties
bottomMarginbasic

--------------------------------------------------------------------------------

Description
Specifies the bottom margin height for HTML print-outs. Cannot be set to be less than the printer's physically unprintable area (unprintableBottom), in which case it will be automatically corrected to the minimum allowed value. If top and bottom margins are set to overlap, they will be corrected to an arbitrary default value of 1/10 of page height.

ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

The bottomMargin property is part of the basic freely-distributable printing subset.

Syntax
printing.bottomMargin = numMargin

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also
HTML Printing with ScriptX 5.5

leftMargin, pageHeight, pageWidth, portrait, rightMargin, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop

GetMarginMeasure, PageSetup, Print, PrintHTML, SetMarginMeasure

collate

--------------------------------------------------------------------------------

Description
Specifies whether or not to collate the pages of HTML print-outs when more than one copy is printed.

Syntax
printing.collate = true|false

Settings
This is a read/write property. Use true to collate.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

duplex, printer

Print, PrintHTML, PrintSetup

copies

--------------------------------------------------------------------------------

Description
Specifies the number of copies for HTML print-outs.

Syntax
printing.copies = numCopies

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

collate, duplex, printer

Print, PrintHTML, PrintSetup

disableUI

--------------------------------------------------------------------------------

Description
Set to true to disable all of Internet Explorer's printing facilities, including the File/Page Setup, File/Print main menu commands, the Print context menu command and the window.print() scripting method. Given this, the only way left to print is via the ScriptX Print and PrintHTML methods.

Syntax
printing.disableUI = true|false

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Advanced Printing example.

See Also
HTML Printing with ScriptX 5.5

onpagesetup, onuserpagesetup, onuserprint, onuserprintpreview

PageSetup, Preview, Print, PrintSetup

duplex

--------------------------------------------------------------------------------

Description
Duplex mode (if supported by the targeted printer).

Syntax
printing.duplex = number

Settings
This is a read/write property. Use 1 for simplex mode (no duplex), 2 for vertical duplex, 3 for horizontal duplex.

Applies To
printing

See Also
HTML Printing with ScriptX 5.5

collate, copies

Print, PrintHTML, PrintSetup,

footerbasic

--------------------------------------------------------------------------------

Description
Specifies the string to be used as the footer for HTML print-outs. String can include Internet Explrore header/footer metasymbols. If you need to use HTML for your headers and footers, check MaxiPT 1.0?/span> (Internet Explorer 5.5 or later).

The footer property is part of the basic freely-distributable printing subset.

Syntax
printing.footer = sFooter

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also
HTML Printing with ScriptX 5.5

header

PageSetup, Print, PrintHTML

headerbasic

--------------------------------------------------------------------------------

Description
Specifies the string to be used as the header for HTML print-outs. String can include Internet Explrore header/footer metasymbols. If you need to use HTML for your headers and footers, check MaxiPT 1.0?/span> (Internet Explorer 5.5 or later).

The header property is part of the basic freely-distributable printing subset.

To print specific information as part of the header or footer, include the following characters as part of the string:

Shorthand Meaning
&w Window title
&u Page address (URL)
&d Date in short format (as specified by Regional Settings in Control Panel)
&D Date in long format (as specified by Regional Settings in Control Panel)
&t Time in the format specified by Regional Settings in Control Panel
&T Time in 24-hour format
&p Current page number
&P Total number of pages
&& A single ampersand (&)
&b The text immediately following these characters as centered.
&b&b The text immediately following the first "&b" as centered, and the text following the second "&b" as right-justified.

Syntax
printing.header = sHead

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also
HTML Printing with ScriptX 5.5

footer

PageSetup, Print, PrintHTML

leftMarginbasic

--------------------------------------------------------------------------------

Description
Specifies the left margin for HTML print-outs. Cannot be set to be less than the printer's physically unprintable area (unprintableLeft), in which case it will be automatically corrected to the minimum allowed value. If left and right margins overlap, they will be corrected to an arbitrary default value of 1/10 of page width.

ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

The leftMargin property is part of the basic freely-distributable printing subset.

Syntax
printing.leftMargin = numMargin

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also
HTML Printing with ScriptX 5.5

pageHeight, pageWidth, portrait, rightMargin, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop

GetMarginMeasure, PageSetup, Print, PrintHTML, SetMarginMeasure

onafterprint

--------------------------------------------------------------------------------

Description
Event handler to be called when print spooling is done. The event is applicable to the results of a Print call but not to that of a PrintHTML call. It can be used to update the user interface accordingly. It is similar to the WaitForSpoolingComplete blocking call, but is asynchronous.
Note the difference between ScriptX's onafterprint event and the DHTML window.onafterprint?/span> event: the latter occurs after Internet Explroer has just made a document snapshot for printing and not after the actual print spooling job (see PRB: onafterprint Event Fires Before the Print Dialog Box Appears?/span>). So these two events are not interchangeable.

In fact, the DHTML window.onbeforeprint?/span> and window.onafterprint?/span> exist to give the document's script a chance to customize DHTML content before it goes to print-out or preview (and not to signal actual printing). The same effect can be achieved with the CSS media=print or media=screen specific styles. Check out the following InsideDHTML.com articles: Printing Techniques?/span>, Using CSS to specify alternate document to print out?/span>.

Syntax
printing.onafterprint = function_object

Settings
This is a read/write property.

Applies To
printing

Example
<script defer>
factory.printing.onafterprint = AfterPrint;

function AfterPrint() {
alert("The document has been sent to the print spooler!");
}
<script>
See Also
HTML Printing with ScriptX 5.5

onpagesetup, onuserpagesetup, onuserprint, onuserprintpreview

Print, WaitForSpoolingComplete

onbeforeunload

--------------------------------------------------------------------------------

Description
String to prompt a user with when spooling (or a download originated by a PrintHTML call) is still in progress but the page is being closed or navigated away. By default, ScriptX waits 5 seconds in blocking mode to let spooling complete, then prompts the user with the choice to cancel the printing process. The user may decide to wait for another 5 seconds, and so on.
Note: to suppress the prompt you can force the blocking wait state with WaitForSpoolingComplete after any Print or PrintHTML call or before leaving the page. However the use of WaitForSpoolingComplete() after each PrintHTML call in a sequence of calls is not recommended. Use it only after the last call in the sequence.

Syntax
printing.onbeforeunload = string

Settings
This is a read/write property.

Applies To
printing

See Also
HTML Printing with ScriptX 5.5

Print, PrintHTML, WaitForSpoolingComplete

onpagesetup

--------------------------------------------------------------------------------

Description
Event handler to be called when the current print or page setup settings are changed on the Internet Explorer Page Setup dialog.
Use it to update the page's user interface accordingly. This is exactly what the ScriptX Techie Printing example does.

Syntax
printing.onpagesetup = function_object

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

disableUI, onafterprint, onuserpagesetup, onuserprint, onuserprintpreview

PageSetup

onuserpagesetup

--------------------------------------------------------------------------------

Description
Event handler to be called when a user invokes the Page Setup... command from Internet Explorer's File menu.
You may cancel this operation within the event handler simply by returning, or you may call PageSetup to provide the expected behavior. In the latter case, once the user has made changes on the Page Setup dialog an onpagesetup event will be fired to update the page's user interface. ScriptX Techie Printing implements this behavior.

Syntax
printing.onuserpagesetup = function_object

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

disableUI, onafterprint, onpagesetup, onuserprint, onuserprintpreview

PageSetup

onuserprint

--------------------------------------------------------------------------------

Description
Event handler to be called when a user invokes the Print... command from the Internet Explorer File menu, or presses Print on on the document's right-click context menu, or hits the printer button on the toolbar, or presses the Ctrl-P key combination, or when a script calls window.print()?/span>.
You may cancel this operation within the event handler simply by returning, or you may call Print to provide the expected behavior. ScriptX Techie Printing implements this behavior.

Syntax
printing.onuserprint = function_object

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

disableUI, onafterprint, onpagesetup, onuserpagesetup, onuserprintpreview

PageSetup

onuserprintpreview

--------------------------------------------------------------------------------

Description
Event handler to be called when a user invokes the Preview... command from the Internet Explorer File menu or hits the print preview button on the toolbar.
You may cancel this operation within the event handler simply by returning, or you may call Preview to provide the expected behavior. ScriptX Techie Printing implements this behavior.

Syntax
printing.onuserprintpreview = function_object

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

disableUI, onafterprint, onpagesetup, onuserpagesetup, onuserprint

PageSetup

pageHeight

--------------------------------------------------------------------------------

Description
Returns the physical height of the current printer paper selection.
ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

Syntax
height = printing.pageHeight

Settings
This is a read-only property.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

bottomMargin, leftMargin, pageWidth, paperSize, portrait, rightMargin, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop

PageSetup, SetMarginMeasure

pageWidth

--------------------------------------------------------------------------------

Description
Returns the physical width of the current printer paper selection.
ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

Syntax
width = printing.pageWidth

Settings
This is a read-only property.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

bottomMargin, leftMargin, pageHeight, paperSize, portrait, rightMargin, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop

PageSetup, SetMarginMeasure

paperSize

--------------------------------------------------------------------------------

Description
Specifies the paper size for HTML print-outs by its string name. ScriptX tries to find the longest string match amongst the list of available paper size names for the current printer. Read back the paperSize value to see the actual result.

Syntax
printing.paperSize = sPaperSize

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

pageHeight, pageWidth, paperSource, portrait, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop

PageSetup, Print, PrintHTML, PrintSetup

paperSource

--------------------------------------------------------------------------------

Description
Specifies the paper source (tray) for HTML print-outs by its string name. ScriptX tries to find the longest string match amongst the list of available paper source names for the current printer. Read back the paperSource value to see the actual result.

Syntax
printing.paperSource = sPaperSource

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

paperSize

PageSetup, Print, PrintHTML, PrintSetup

portraitbasic

--------------------------------------------------------------------------------

Description
Specifies the page orientation for HTML print-outs.

The portrait property is part of the basic freely-distributable printing subset.

Syntax
printing.portrait = true|false

Settings
This is a read/write property. Use true to specify portrait and false for landscape.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

bottomMargin, leftMargin, pageHeight, pageWidth, paperSize, templateURL, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop

PageSetup, Print, PrintHTML, PrintSetup

printBackground

--------------------------------------------------------------------------------

Description
Specifies whether or not to print a page's background colors and images.

Syntax
printing.printBackground = true|false

Settings
This is a write-only property.

Applies To
printing

Example
Check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

Preview, Print, PrintHTML

printer

--------------------------------------------------------------------------------

Description
Specifies the printer to print to. Only the exact printer name strings as they appear on Internet Explorer's Print dialog can be specified. If the string does not exist or is written wrongly, printing will be directed to the default printer.

Syntax
printing.printer = sPrinterName

Settings
This a write-only property. With JScript, take care to double a backslash if one appears in the printer name, as in the example below.

Applies To
printing

Example
factory.printing.printer = "\\\\FS-LYS-01\\HP5n-759" // print to \\FS-LYS-01\HP5n-759
Also check out the source code of the ScriptX Techie Printing example.

See Also
HTML Printing with ScriptX 5.5

bottomMargin, collate, copies, duplex, footer, header, leftMargin, paperSize, paperSource, portrait, printBackground, printToFileName, rightMargin, templateURL, topMargin

DefaultPrinter, EnumJobs, EnumPrinters, GetJobsCount, IsSpooling, IsTemplateSupported, PrintHTML, PrintSetup, SetPageRange, WaitForSpoolingComplete

printToFileName

--------------------------------------------------------------------------------

Description
The file name to print to. Use the full path specification. The file created doesn't accumulate subsequent print-outs and - for security reasons - doesn't get overwritten if it already exists. Specify a new filename for each new print-out.

Printing to file name is supported for Internet Explore 5.0 and later.

Syntax
printing.printToFileName = sPathFileName

Settings
This is a read/write property. With JScript, take care to double a backslash if one appears in the file path, as in the example below. An empty string indicates that the print-out should go to the printer driver.

Applies To
printing

Example
factory.printing.printToFileName = "d:\\temp\\printout.prn"
See Also
HTML Printing with ScriptX 5.5

printer

IsSpooling, Print, PrintHTML, PrintSetup, WaitForSpoolingComplete

rightMarginbasic

--------------------------------------------------------------------------------

Description
Specifies the right margin for HTML print-outs. Cannot be set to be less than the printer's physically unprintable area (unprintableRight), in which case it will be automatically corrected to the minimum allowed value. If left and right margins overlap, they will be corrected to an arbitrary default value of 1/10 of page width.

ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

The rightMargin property is part of the basic freely-distributable printing subset.

Syntax
printing.rightMargin = numMargin

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also
HTML Printing with ScriptX 5.5

pageHeight, pageWidth, portrait, leftMargin, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop

GetMarginMeasure, PageSetup, Print, PrintHTML, SetMarginMeasure

templateURL

--------------------------------------------------------------------------------

Description
Specifies the URL of a custom Print Template?/span> for Internet Explorer 5.5 or later. Internet Explorer will use the specified template for all its printing operations.
If you use your own templates with ScriptX 5.5, make sure that you insert a MeadCo's TriPrint Helper <OBJECT> into the <HEAD> section of the print template source:

<HTML XMLNS:IE>
<HEAD>
<?IMPORT namespace="ie" implementation="#default">

<!-- <TriPrint> (c) 2000, 2001 by Mead & Co Limited <triprint@meadroid.com> -->
<object classid="clsid:1663ed6a-23eb-11d2-b92f-008048fdd814" viewastext>
<param name="__PX__template" value="true">
</object>
<!-- </TriPrint> -->

<TITLE>Print Preview</TITLE>
Syntax
printing.templateURL = templateURL

Settings
This is a read/write property.

Applies To
printing

Example
Read more about MeadCo's in-depth support for Print Templates?/span>.

See Also
IsTemplateSupported, Print, PrintHTML

topMarginbasic

--------------------------------------------------------------------------------

Description
Specifies the top margin for HTML print-outs. Cannot be set to be less than the printer's physically unprintable area (unprintableTop), in which case it will be automatically corrected to the minimum allowed value. If top and bottom margins overlap, they will be corrected to default value of 1/10 of page width.

ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

The topMargin property is part of the basic freely-distributable printing subset.

Syntax
printing.topMargin = numMargin

Settings
This is a read/write property.

Applies To
printing

Example
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also
HTML Printing with ScriptX 5.5

leftMargin, pageHeight, pageWidth, portrait, rightMargin, bottomMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop

GetMarginMeasure, PageSetup, Print, PrintHTML, SetMarginMeasure

unprintableBottom

--------------------------------------------------------------------------------

Description
Returns the bottom unprintable page area (in current system measure units, inches or millimeters) for the current printer. It indicates the distance from the bottom edge of the page where no printing may occur.

Syntax
numMargin = printing.unprintableBottom

Settings
This a read/only property.

Applies To
printing

See Also
HTML Printing with ScriptX 5.5

bottomMargin, leftMargin, pageHeight, pageWidth, paperSize, topMargin, unprintableLeft, unprintableRight, unprintableTop

PageSetup, Print, PrintSetup

unprintableLeft

--------------------------------------------------------------------------------

Description
Returns the left unprintable page area (in current system measure units, inches or millimeters) for the current printer. It indicates the distance from the left edge of the page where no printing may occur.

Syntax
numMargin = printing.unprintableLeft

Settings
This a read/only property.

Applies To
printing

See Also
HTML Printing with ScriptX 5.5

bottomMargin, leftMargin, pageHeight, pageWidth, paperSize, topMargin, unprintableBottom, unprintableRight, unprintableTop

PageSetup, Print, PrintSetup

unprintableRight

--------------------------------------------------------------------------------

Description
Returns the right unprintable page area (in current system measure units, inches or millimeters) for the current printer. It indicates the distance from the right edge of the page where no printing may occur.

Syntax
numMargin = printing.unprintableRight

Settings
This a read/only property.

Applies To
printing

See Also
HTML Printing with ScriptX 5.5

bottomMargin, leftMargin, pageHeight, pageWidth, paperSize, topMargin, unprintableBottom, unprintableLeft, unprintableTop

PageSetup, Print, PrintSetup

unprintableTop

--------------------------------------------------------------------------------

Description
Returns the top unprintable page area (in current system measure units, inches or millimeters) for the current printer. It indicates the distance from the top edge of the page where no printing may occur.

Syntax
numMargin = printing.unprintableTop

Settings
This a read/only property.

Applies To
printing

See Also
HTML Printing with ScriptX 5.5

bottomMargin, leftMargin, pageHeight, pageWidth, paperSize, topMargin, unprintableBottom, unprintableLeft, unprintableRight

PageSetup, Print, PrintSetup



Methods and Functions
BatchPrintPDF

--------------------------------------------------------------------------------

Description
Downloads Adobe Acrobattm or Microsoft Officetm files and prints them out in batch mode in the background. Any number of print-outs can be queued. As of the present release of ScriptX, BatchPrintPDF prints only on the default printer using default settings.

To print PDF files, the Adobe Acrobat Readertm 4.0 or later should be present on the client system. It can be freely downloaded from the Adobe website?/span>.

Use IsSpooling to check if there are any outstanding downloads in the queue created by BatchPrintPDF. Use WaitForSpoolingComplete to wait for all documents to be downloadloaded and spooled.

Syntax
printing.BatchPrintPDF(url)

Example
Here is a basic example of BatchPrintPDF use

<body>

<!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=5,60,0,360">
<param name="GUID" value="{1FB3613D-2B04-11D4-A695-0000863B364E}">
<param name="Path" value="sxlic.mlf">
</object>

<!-- MeadCo ScriptX -->
<object id="factory" viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="smsx.cab#Version=5,60,0,360">
</object>

<script defer>
function window.onload() {
idPrint.disabled = false;
}

function BatchPrintPDF(url) {
factory.printing.BatchPrintPDF(url);
}
</script>

<input id=idPrint disabled type="button" value="PrintHTML('info.htm')"
onclick="BatchPrintPDF('report.pdf')">

</body>
Applies To
printing

See Also
HTML Printing with ScriptX 5.5

DefaultPrinter, EnumJobs, EnumPrinters, GetJobsCount, IsSpooling, PrintHTML, PrintPDF, Sleep, WaitForSpoolingComplete

DefaultPrinter

--------------------------------------------------------------------------------

Description
Returns the name of the default printer (if any).

Syntax
printerName = printing.DefaultPrinter()

Applies To
printing

See Also
HTML Printing with ScriptX 5.5

printer

EnumJobs, EnumPrinters, GetJobsCount, IsTemplateSupported, Print

DoPrint

--------------------------------------------------------------------------------

Description
The alias for the Print method (retained for compatibility reasons).

Applies To
factory

See Also
printing, Print, PrintHTML

EnumJobs

--------------------------------------------------------------------------------

Description
Enumerates active jobs on the given printer.

Syntax
var jobName = {}
status = printing.EnumJobs(printerName, index, jobName)

Parameter Description
printerName (String) printer name on which to enumerate the jobs
index (Number) Zero-based index of the job. Increment this value for each new EnumJobs call for a given printerName
jobName (Object) obtains a name for the job (available as jobName[0])

Return Value
Returns a numeric value indicating the current status of the job. The bits have the following meaning:

Meaning Value
JOB_STATUS_PAUSED 0x00000001
JOB_STATUS_ERROR 0x00000002
JOB_STATUS_DELETING 0x00000004
JOB_STATUS_SPOOLING 0x00000008
JOB_STATUS_PRINTING 0x00000010
JOB_STATUS_OFFLINE 0x00000020
JOB_STATUS_PAPEROUT 0x00000040
JOB_STATUS_PRINTED 0x00000080
JOB_STATUS_DELETED 0x00000100
JOB_STATUS_BLOCKED_DEVQ 0x00000200
JOB_STATUS_USER_INTERVENTION 0x00000400
JOB_STATUS_RESTART 0x00000800

Example
<script defer>
function window.onload() {
for ( i = 0; printer = factory.printing.EnumPrinters(i); i++ ) {
alert("Printer name: "+printer);
var job = {};
for ( j = 0; status = factory.printing.EnumJobs(printer, j, job); j++ )
alert("Job name: "+job[0]+", status: "+status);
}
}
</script>
Applies To
printing

See Also
HTML Printing with ScriptX 5.5

printer

DefaultPrinter, EnumPrinters, GetJobsCount, Print

EnumPrinters

--------------------------------------------------------------------------------

Description
Enumerates locally-available printers.

Syntax
printerName = printing.EnumPrinters(index)

Parameter Description
index (Number) Zero-based index of the printer. Increment this value for each new EnumPrinters call

Return Value
Returns the string name of the next printer. An empty value means that enumeration is over.

Example
<!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=5,60,0,360">
<param name="GUID" value="{1FB3613D-2B04-11D4-A695-0000863B364E}">
<param name="Path" value="sxlic.mlf">
</object>

<!-- MeadCo ScriptX -->
<object id="factory" viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="smsx.cab#Version=5,60,0,360">
</object>

<p><small id=idOutput></small>

<script defer>
function OutputHtml(html) {
idOutput.insertAdjacentHTML("BeforeEnd", html)
idOutput.scrollIntoView(false)
}

function EnumAll() {
OutputHtml("Default printer: <b>" + factory.printing.DefaultPrinter() + "</b><br>")
for ( i = 0; name = factory.printing.EnumPrinters(i); i++ ) {
OutputHtml("Printer: <b>" + name + "</b><br>Job count: " + factory.printing.GetJobsCount(name) + "<br>")
var jobName = {}
for ( j = 0; status = factory.printing.EnumJobs(name, j, jobName); j++ )
OutputHtml("Job: <b>" + jobName[0]+"</b>Status: " + new Number(status).toString(16) + "<br>")
}
}

function window.onload() {
EnumAll()
}
</script>
Applies To
printing

See Also
HTML Printing with ScriptX 5.5

printer

DefaultPrinter, EnumJobs, EnumPrinters, GetJobsCount, Print, PrintSetup

GetJobsCount

--------------------------------------------------------------------------------

Description
Returns the number of printing jobs for the specified printer.

Syntax
numJobs = printing.GetJobsCount(printer)

Return Value
Returns a numeric value.

Applies To
printing

See Also
HTML Printing with ScriptX 5.5

printer

DefaultPrinter, EnumJobs, EnumPrinters, Print

GetMarginMeasure

--------------------------------------------------------------------------------

Description
Returns current units of measure for print-out margins, either millimeters or inches. Use SetMarginMeasure to switch the default units.

Syntax
units = printing.GetMarginMeasure()

Return Value
Returns the currently-set units of measure. 1 stands for millimeters, 2 for inches.

Applies To
printing

Example
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also
HTML Printing with ScriptX 5.5

bottomMargin, leftMargin, pageHeight, pageWidth, rightMargin, templateURL, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop

PageSetup, Print, PrintPrintSetup, SetMarginMeasure

IsSpooling

--------------------------------------------------------------------------------

Description
Checks if spooling is in progress as result of a Print call, or for any downloads outstanding in the queue created by PrintHTML, PrintXML or BatchPrintPDF calls.

You can force the blocking wait state with WaitForSpoolingComplete to make sure all downloads are complete and spooling is done at any point in your code.

Syntax
isSpooling = printing.IsSpooling()

Return Value
Returns a boolean value indicating whether or not there are still outstanding unspooled downloads to be printed

Example
The following example closes the window when the spooling is done:

<script defer>

function PrintAllDocs() {
factory.printing.PrintHTML("info.htm");
factory.printing.PrintXML(src1);
factory.printing.PrintXML(src2);
CheckSpooling();
}

function CheckSpooling() {
if ( !factory.printing.IsSpooling() ) window.close()
setTimeout("CheckSpooling()", 1000);
}

</script>
See Also
HTML Printing with ScriptX 5.5

onafterprint, onbeforeunload

BatchPrintPDF, OwnQueue, Print, PrintHTML, PrintXML, Sleep, WaitForSpoolingComplete

IsTemplateSupported

--------------------------------------------------------------------------------

Description
Checks whether or not Print Templates?/span> are supported on the end user's system (i.e. checks for Internet Explorer 5.5 or later).

Syntax
isTemplateSupported = printing.IsTemplateSupported()

Return Value
Returns a boolean value indicating whether or not Print Templates are supported.

Applies To
printing

See Also
HTML Printing with ScriptX 5.5

templateURL

Preview, Print, PrintHTML

OwnQueue

--------------------------------------------------------------------------------

Description
OwnQueue is used to organize a detached printing queue. Use this method to queue all PrintHTML calls in a separate process. The process is disconnected from the current session (cookies, SSL context, etc) but the calling window can be closed at any time without waiting for spooling to compete.

OwnQueue should be called before any PrintHTML or PrintXML commands to take effect.

Syntax
printing.OwnQueue()

Applies To
printing

See Also
PrintHTML, PrintXML

PageSetupbasic

--------------------------------------------------------------------------------

Description
Invokes the standard Internet Explorer Page Setup... dialog. If the user closes the dialog with the OK button, current settings will be updated and an onpagesetup event will be fired.

The PageSetup method is part of the basic freely-distributable printing subset.

Syntax
result = printing.PageSetup()

Return Value
Returns a boolean value indicating whether or not a user has closed the dialog with the OK button.

Example
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

Applies To
printing

See Also
HTML Printing with ScriptX 5.5

bottomMargin, disableUI, footer, header, leftMargin, onpagesetup, onuserpagesetup, paperSize, paperSource, portrait, rightMargin, topMargin

Print, PrintHTML, PrintSetup

Previewbasic

--------------------------------------------------------------------------------

Description
Invokes the Print Preview... pane in Internet Explorer 5.5 and later.

The Preview method is part of the basic freely-distributable printing subset.

Syntax
printing.Preview()

Applies To
printing

Example
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also
HTML Printing with ScriptX 5.5

onuserprintpreview, templateURL

IsTemplateSupported, Print

Printbasic

--------------------------------------------------------------------------------

Description
Prints the contents of the specified window or frame using the current printing settings. Please note these important changes regarding printing without a prompt.

This method is part of the basic freely-distributable printing subset.

However, the acquisition of a MeadCo Publishing License?/span> means that you can customize various printing properties such as copies, duplex, paperSize, printBackground etc., target specific printer or print externally-located documents with PrintHTML. See HTML Printing with ScriptX 5.5 for more info.

Syntax
printing.Print([prompt[, frameOrWindow]])

Parameter Description
prompt (Bool) whether or not to prompt
frameOrWindow (Object) optional HTML frame or window?/span> to print. By default, the containing page (that hosts the ScriptX object) will be printed

Return Value
Returns false if printing with a prompt and the user cancels the printing.

Example
Check out the source code of the ScriptX Basic, Advanced and Techie printing examples.

The following simple but complete example shows how to print the containing page:

<head>
<title>MeadCo's ScriptX: Print</title>
<!-- special style sheet for printing -->
<style media="print">
.noprint { display: none }
</style>
</head>

<body scroll="auto">

<!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=5,60,0,360">
<param name="GUID" value="{1FB3613D-2B04-11D4-A695-0000863B364E}">
<param name="Path" value="sxlic.mlf">
</object>

<!-- MeadCo ScriptX -->
<object id="factory" viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="smsx.cab#Version=5,60,0,360">
</object>

<script defer>
function window.onload() {
factory.printing.header = "MeadCo's ScriptX: Print"
factory.printing.footer = "The de facto standard for advanced web-based printing"
factory.printing.portrait = false
idPrint.disabled = false; // enable UI button
}

function Print() {
factory.printing.Print(false); // no prompt
}
</script>

<p>Hello, world!</p>

<div class=noprint>
<hr>The button itself will not be printed:
<input id=idPrint disabled type="button" value="Print w/o prompt" onclick="Print()">
</div>

</body>
Applies To
printing

See Also
HTML Printing with ScriptX 5.5

bottomMargin, collate, copies, duplex, footer, header, leftMargin, onafterprint, onuserprint, paperSize, paperSource, portrait, printBackground, printer, printToFileName, rightMargin, templateURL, topMargin

DefaultPrinter, EnumJobs, EnumPrinters, GetJobsCount, GetMarginMeasure, IsSpooling, IsTemplateSupported, OwnQueue, PageSetup, Preview, Print, PrintHTML, PrintPDF, PrintSetup, PrintXML, SetMarginMeasure, SetPageRange, WaitForSpoolingComplete

PrintHTML

--------------------------------------------------------------------------------

Description
Prints the HTML or XML document specified by the URL using the current printing settings in the same session context. The method is asynchronous. It returns before the document is downloaded and printed.

PrintHTML may be used to organize a printing queue in a separate process, in which case the current window may be closed without waiting for pending downloads to complete. See OwnQueue for more details.

Syntax
printing.PrintHTML(url[, prompt = false])

Parameter Description
url (String) URL to print
prompt (Bool) Specifies whether or not the user should be prompted before the download is queued

Return Value
Returns false if printing with a prompt and the user cancels the printing.

Applies To
printing

Examples
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

The following simple but complete example shows how to print an externally-located document:

<body>

<!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=5,60,0,360">
<param name="GUID" value="{1FB3613D-2B04-11D4-A695-0000863B364E}">
<param name="Path" value="sxlic.mlf">
</object>

<!-- MeadCo ScriptX -->
<object id="factory" viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="smsx.cab#Version=5,60,0,360">
</object>

<script defer>
孟子E章 2001-06-23
  • 打赏
  • 举报
回复
ScriptX scripting: technical manual

April, 2001

Download this document set [Requires Microsoft Internet Explorer 5.0?/span> or later]

Contents
Overview
How to put ScriptX on an HTML page
General scripting extensions
Dynamic Event Binding (DEB)
DHTML dialogs
JScript: SafeArrays, Invoke 'ByRef', Formatting
Internet Explorer specific functionality
Technical support
Reference

Summary of examples
Dynamic Event Binding with JScript and VBScript (Windows Scripting Host?/span>)
Modal HTML Dialog
SafeArrays with JScript
Invoke 'By Ref' with JScript
Formatting with JScript
OleView-based Object Viewer
Overview
MeadCo ScriptX is a non-visual ActiveX control, originally designed to extend the scripting capabilities of the standard Microsoft Scripting Languages JScript?/span> and VBScript?/span> and to add more resemblance between the two. Currently the functionality provided by ScriptX can be conditionally grouped under the following headings:

HTML Printing
General scripting extensions
Internet Explorer specific functionality
All ScriptX functionality is licensed free of charge, with the exception of the control's advanced printing features which are only accessible in the presence of a paid-for license. HTML Printing facilities are described in the printing manual.

How to put ScriptX on an HTML page
ScriptX comes in two signed CABs: ScriptX.cab or smsx.cab, both of which are part of a download package obtainable from the ScriptX site?/span>. All free-of-charge functionality is available in ScriptX.cab:

<object id=factory style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
viewastext codebase="ScriptX.cab#Version=5,60,0,360">
</object>
The viewastext parameter prevents an authoring tool like FrontPage or Visual Interdev from instantiating the object at design time.

General scripting extensions
General scripting extensions are independent of a particular scripting host. They are used as extensions to the default scripting runtime environment.

Dynamic Event Binding (DEB)

As its name may indicate, DEB enables the binding/unbinding of a script handler to any ActiveX object event on the fly. It works well for all Active Scripting hosts: WSH, HTML or custom.

Another useful DEB feature is Wait, the ability to 'sleep' script execution (with an optional timeout) without 'eating' any CPU cycles until an event occurs. 'Sleep' is conceptually close to VB's DoEvents?/span> statement in that it serves the application message loop.

The best way to illustrate DEB is by example. Here is a Windows Scripting Host (WSH?/span>) example in both JScript and VBScript that creates and navigates an instance of the InternetExplorer?/span> object and hooks up to its events.

See also: eventSink, NewEventSink, Wait, CancelWait.

DHTML dialogs

Here is an example of a native look & feel HTML dialog.

See also: ShowHtmlDialog.

JScript: SafeArrays, Invoke 'ByRef', Formatting

These extensions were designed to provide JScript with more resemblance to VBScript.

Jscript has limited read-only support for VB Arrays?/span> (also known as SafeArrays) with a VBArray?/span> object. ScriptX allows the creation of -- and direct access to -- a SafeArray with JScript. It's now possible to convert a JScript Array?/span> to a SafeArray. Note that only single dimension SafeArrays are supported. Here is an example illustrating SafeArrays with JScript.

See also: Vec, VecFill, VecCopy, VecFromArray, VecGetSize, VecResize, VecPut, VecGet

Invoke 'ByRef' was developed to allow JScript to call ActiveX controls that take byref arguments. It also allows OLE errors that the calling method may return to be handled, and any corresponding script exceptions to be avoided. Here is an example illustrating how to use InvokeByRefResult with JScript.

See also: InvokeByRef, InvokeByRefResult.

Formatting functions match those of VBScript. They require the newer OLE Automation binaries to be available (they're part of Windows 98, come with Internet Explorer 5, or can be downloaded as part of free Visual Basic 6.0 Run-Time?/span>, see MSKB Q192461?/span>). Here is an example of JScript formatting.

See also: Format, FormatCurrency?/span>, FormatDateTime?/span>, FormatNumber?/span>, FormatPercent?/span>.

Object Viewer

It's possible to learn on the fly what methods and properties an object supports. Microsoft's OleViewer?/span> is required and is available for free download?/span>. Here is an example of how to use the object viewer which shows the object model of an HTML window?/span> and the ScriptX factory object itself.

Other

See also: Shutdown, IsClosed, GetComponentVersion, MessageBeep, MessageBox.

Internet Explorer specific functionality
When ScriptX is hosted as an <OBJECT> on an HTML page, it provides the following Internet Explorer specific functionality:

get the full HTML source of the hosting page page (sourceText)
handle the download completetion of a child frame or window (OnDocumentComplete)
obtain a full (baseURL) or relative (relativeURL) URL based on the hosting page URL
Technical support
For basic ScriptX functionality, we provide free peer-to-peer technical support at the public ScriptX News Group.


--------------------------------------------------------------------------------

Reference
Objects
factory, js, printing, eventSink

Properties
baseURL, ctx, js, handler, relativeURL, script, src

Methods
CancelWait, InvokeByRef, InvokeByRefResult, IsClosed, Format, FormatCurrency, FormatDateTime, FormatNumber, FormatPercent, GetComponentVersion, MessageBeep, MessageBox, NewEventSink, OnDocumentComplete, ShowHtmlDialog, Shutdown, Unadvise, Vec, VecCopy, VecFill, VecFromArray, VecGet, VecGetSize, VecResize, VecPut, Wait

Objects
factory

--------------------------------------------------------------------------------

Description
Represents the ScriptX object itself as it is named on an HTML page.

For WSH or ASP (i.e. server-side) use only it's possible to create a ScriptX instance dynamically with the JScript new ActiveXObject?/span> or the VBScript CreateObject?/span>. In such cases the Shutdown method should be called when ScriptX is no longer being used.

Properties
script, baseURL, relativeURL, printing, js, sourceText

Methods
NewEventSink, IsClosed, Shutdown, ShowHtmlDialog, MessageBeep, MessageBox, Wait, CancelWait, OnDocumentComplete, GetComponentVersion

js

--------------------------------------------------------------------------------

Description
Represents ScriptX helper facilities for JScript. See JScript: SafeArrays, Invoke 'ByRef', Formatting for more information and examples.

Methods
Vec, VecFill, VecCopy, VecFromArray, VecGetSize, VecResize, VecPut, VecGet, Format, FormatCurrency, FormatDateTime, FormatNumber, FormatPercent, InvokeByRef, InvokeByRefResult

Applies To
factory

eventSink

--------------------------------------------------------------------------------

Description
An object used to connect script handlers to, or disconnect them from, events of an ActiveX control. The object is created dynamically with the NewEventSink method. See Dynamic Event Binding (DEB) for more information.

Properties
handler, src, ctx

Methods
Wait, CancelWait, Unadvise

See Also
NewEventSink

Properties
script

--------------------------------------------------------------------------------

Description
This property is for use with dynamic event binding, when a ScriptX object is created dynamically with VBscript. In this case the script namespace object should be assigned to this property, because ScriptX looks for an event handler by name. See the example below.

Syntax
factory.script = object

Settings
This read/write property takes an object that has all the event handlers defined within.

Applies To
factory

Example
' Handle events from browser
Set Browser = CreateObject("InternetExplorer.Application")
Browser.Visible = true

Set Factory = CreateObject("ScriptX.Factory")
Factory.script = me
Set Sink = Factory.NewEventSink(Browser)
Sink("BeforeNavigate2")="BeforeNavigate2"
Sink("DocumentComplete")="DocumentComplete"
Sink("OnQuit")="OnQuit"

Sub BeforeNavigate2(ByVal pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel)
' handling code
End Sub

Sub DocumentComplete(ByVal pDisp, URL)
' handling code
End Sub

Sub OnQuit
' handling code
End Sub
See Also
NewEventSink

baseURL

--------------------------------------------------------------------------------

Description
This property is for use in an HTML script. It returns a full URL based upon the URL of the hosting document.

Syntax
fullUrl = factory.baseURL[(url)]

Settings
This is a read-only property which returns either the full URL of the hosting document or the base url of the document's URL.

Applies To
factory

Example
<script>
function window.onload() {
childWindow.navigate(factory.baseURL("loaded.htm"))
}
</script>
See Also
relativeURL

relativeURL

--------------------------------------------------------------------------------

Description
This property is for use in an HTML script. It returns the URL relative to the hosting document's URL.

Syntax
relUrl = factory.relativeURL[(url)]

Settings
This is a read-only property.

Applies To
factory

See Also
baseURL

sourceText

--------------------------------------------------------------------------------

Description
This property is for use in an HTML script. It retrieves the raw HTML source of the hosting document.

Syntax
htmlText = factory.sourceText

Settings
This is a read-only property.

Applies To
factory

handler

--------------------------------------------------------------------------------

Description
This is the default property of the eventSink object. It is used to connect or disconnect a script event handler to or from a specified event. See dynamic event binding for more information.

Syntax
eventSink.handler(sEventName) = EventHandler

or

eventSink(sEventName) = EventHandler

or

eventSink(sEventName) = null

Settings
This is a read/write property. EventHandler can be either the string name of a script function or a direct function reference. null is used to disconnect the event hander.

Example
sink("StatusTextChange") = onStatusTextChange
function onStatusTextChange(Text) { /* handling code */ }
Applies To
eventSink

See Also
eventSink, src, ctx, NewEventSink

src

--------------------------------------------------------------------------------

Description
Specifies the event source object passed to NewEventSink. See dynamic event binding for more information.

Settings
This is a read-only property.

Applies To
eventSink

See Also
handler, ctx, NewEventSink

ctx

--------------------------------------------------------------------------------

Description
Specifies the context value assigned to the eventSink object with NewEventSink. See dynamic event binding for more information.

Settings
This is a read-only property.

Applies To
eventSink

See Also
handler, src, NewEventSink

Methods
NewEventSink

--------------------------------------------------------------------------------

Description
Creates a new event sink for a given object for dynamic event binding. To handle an event, a script handler must be assigned to the sink with the handler property. An optional context value can be passed to be available at the event handler when the event occurs.

Syntax
eventSink = factory.NewEventSink(src[, ctx])

Parameter Description
src (Object) the object to handle events from
ctx (Any type) optional context value

Return Value
Returns a new eventSink object. At event time the object is available to the script handler via implicit this (JScript) or me (VBScript) reference.

Applies To
factory

Example
var browser = new ActiveXObject("InternetExplorer.Application")
var sink = factory.NewEventSink(browser)
sink("StatusTextChange") = onStatusTextChange
sink("NavigateComplete2") = onNavigateComplete2
sink("DocumentComplete") = onDocumentComplete
sink("OnQuit") = onQuit
browser.Navigate2("http://www.meadroid.com")
sink.Wait()
// ...
factory.Shutdown()

// handlers
function onStatusTextChange(Text) { /* handling code */ }
function onNavigateComplete2(pDisp, URL) { /* handling code */ }
function onDocumentComplete(pDisp, URL) { this.CancelWait() }
function onQuit() { this.Unadvise() }
See Also
eventSink, handler, src, ctx, Wait, CancelWait, Unadvise, Shutdown

Wait

--------------------------------------------------------------------------------

Description
Suspends (sleeps) the script execution for a specified timeout or until CancelWait is called. Events are serviced during sleep.

Syntax
object.Wait([timeout])

Parameter Description
timeout (Number) the optional timeout in milliseconds, -1 by default means to sleep until CancelWait is called.

Return Value
Returns true if the sleep was timed out.

Applies To
factory, eventSink

Example
var browser = new ActiveXObject("InternetExplorer.Application")
var sink = factory.NewEventSink(browser)
sink("DocumentComplete") = onDocumentComplete
sink("OnQuit") = onQuit
browser.Navigate2("http://www.meadroid.com")
sink.Wait()
// ...
factory.Shutdown()

// handlers
function onDocumentComplete(pDisp, URL) { this.CancelWait() }
function onQuit() { this.Unadvise() }
See Also
CancelWait

CancelWait

--------------------------------------------------------------------------------

Description
Cancels the pending sleep (that is, the active Wait call).

Syntax
object.CancelWait()

Applies To
factory, eventSink

Example
var browser = new ActiveXObject("InternetExplorer.Application")
var sink = factory.NewEventSink(browser)
sink("StatusTextChange") = onStatusTextChange
sink("NavigateComplete2") = onNavigateComplete2
sink("DocumentComplete") = onDocumentComplete
sink("OnQuit") = onQuit
browser.Navigate2("http://www.meadroid.com")
sink.Wait()
// ...
factory.Shutdown()

// handlers
function onStatusTextChange(Text) { /* handling code */ }
function onNavigateComplete2(pDisp, URL) { /* handling code */ }
function onDocumentComplete(pDisp, URL) { this.CancelWait() }
function onQuit() { this.Unadvise() }
See Also
Wait

Unadvise

--------------------------------------------------------------------------------

Description
Disconnects (unadvises) the eventSink object from its event source.

Syntax
eventSink.Unadvise()

Applies To
eventSink

Example
var browser = new ActiveXObject("InternetExplorer.Application")
var sink = factory.NewEventSink(browser)
sink("OnQuit") = onQuit
browser.Navigate2("http://www.meadroid.com")
sink.Wait()

// handlers
function onQuit() { this.Unadvise() }
See Also
NewEventSink

Shutdown

--------------------------------------------------------------------------------

Description
The clean-up method for ScriptX. Should be called in cases where a dynamically created ScriptX object is no longer being used. All active event sinks get disconnected.

Syntax
factory.Shutdown()

Applies To
factory

IsClosed

--------------------------------------------------------------------------------

Description
Checks whether or not the remote object is shut down. E.g. this can be a pop-up HTML window.

Syntax
closed = factory.IsClosed(obj)

Parameter Description
obj (Object) the remote object to check.

Applies To
factory

Example
function IsWindowClosed(popup) {
return !popup || factory.IsClosed(popup) || popup.closed;
}
ShowHtmlDialog

--------------------------------------------------------------------------------

Description
Invokes a native look & feel modal HTML dialog. See DHTML dialogs for more information and an example.

Syntax
result = factory.ShowHtmlDialog(url, argIn[, options])

Parameter Description
url (String) the URL of HTML page to be a dialog
argIn (Any type) input parameter to reference within dialog
options (String) optional features. See showModalDialog?/span> on MSDN.

Applies To
factory

See Also
showModalDialog?/span>

GetComponentVersion

--------------------------------------------------------------------------------

Description
Retrieves the versioning information of a specified component.

Syntax
factory.GetComponentVersion(class, a, b, c, d)

Parameter Description
class (String) either class name or GUID
a, b, c, d (Number) variables to receive four digits version info

Examples
' VBScript
dim a, b, c, d
on error resume next
factory.GetComponentVersion "msxml", a, b, c, d
error = Err.Number
on error goto 0
if error = 0 then alert "msxml version: " & a & "." & b & "." & c & "." & d
Applies To
factory

Vec

--------------------------------------------------------------------------------

Description
Creates a single-dimensional SafeArray (vector) of a specified size. See SafeArrays for more information and an example.

Syntax
vec = js.Vec(size)

Parameter Description
size (Number) number of elements in new vector

Return Value
Returns the value of a SafeArray type.

Applies To
js

See Also
VecFill, VecCopy, VecFromArray, VecGetSize, VecResize, VecPut, VecGet

VecFill

--------------------------------------------------------------------------------

Description
Creates a one-dimensional SafeArray (vector) containing the specified elements. See SafeArrays for more information and an example.

Syntax
vec = js.VecFill(elem1[, elem2[, ...]])

Parameter Description
elem1...elemN (Any type) elements to fill the vector with

Return Value
Returns the value of a SafeArray type.

Applies To
js

See Also
Vec, VecCopy, VecFromArray, VecGetSize, VecResize, VecPut, VecGet

VecCopy

--------------------------------------------------------------------------------

Description
Creates a copy of a specified one-dimensional SafeArray (vector). See SafeArrays for more information and an example.

Syntax
vec = js.VecCopy(srcVec)

Parameter Description
srcVec (SafeArray) source vector to make a copy of

Return Value
Returns the value of a SafeArray type.

Applies To
js

See Also
Vec, VecFill, VecFromArray, VecGetSize, VecResize, VecPut, VecGet

VecFromArray

--------------------------------------------------------------------------------

Description
Creates a one-dimensional SafeArray (vector) from a JScript array. See SafeArrays for more information and an example.

Syntax
vec = js.VecFromArray(array)

Parameter Description
array (Array) a source JScript array

Return Value
Returns the value of a SafeArray type.

Applies To
js

See Also
Vec, VecFill, VecCopy, VecGetSize, VecResize, VecPut, VecGet

VecGetSize

--------------------------------------------------------------------------------

Description
Retrieves the size of specified one-dimensional SafeArray (vector). See SafeArrays for more information and example.

Syntax
size = js.VecGetSize(vec)

Parameter Description
vec (SafeArray) vector

Return Value
Returns the size of the vector.

Applies To
js

See Also
Vec, VecFill, VecCopy, VecFromArray, VecResize, VecPut, VecGet

VecResize

--------------------------------------------------------------------------------

Description
Changes the size of a specified one-dimensional SafeArray (vector). See SafeArrays for more information and an example.

Syntax
js.VecResize(vec, newSize)

Parameter Description
vec (SafeArray) vector
newSize (Number) new size of the vector

Applies To
js

See Also
Vec, VecFill, VecCopy, VecFromArray, VecGetSize, VecPut, VecGet

VecPut

--------------------------------------------------------------------------------

Description
Puts the element at the specified position of a one-dimensional SafeArray (vector). See SafeArrays for more information and an example.

Syntax
js.VecPut(vec, pos, elem)

Parameter Description
vec (SafeArray) vector
pos (Number) position
elem (Any type) element to put at the position

Applies To
js

See Also
Vec, VecFill, VecCopy, VecFromArray, VecGetSize, VecGet

VecGet

--------------------------------------------------------------------------------

Description
Retrieves the element at the specified position of a one-dimensional SafeArray (vector). See SafeArrays for more information and example.

Syntax
elem = js.VecGet(vec, pos)

Parameter Description
vec (SafeArray) vector
pos (Number) position

Return Value
Returns the element at the specified position.

Applies To
js

See Also
Vec, VecFill, VecCopy, VecFromArray, VecGetSize, VecPut

Format

--------------------------------------------------------------------------------

Description
Formats the data according to the corresponding format specification. See Formatting for more information and an example.

Syntax
string = js.Format(strFormat[, param1[, param2[, ...]]])

Parameter Description
strFromat (String) the format-control specification. See remarks below
param1...param2 (Type as specifed at strFromat) paramters to format

Remarks
The format-control string contains format specifications that determines the output format for the arguments following the strFromat parameter. Format specifications, discussed below, always begin with a percent sign (%). If a percent sign is followed by a character that has no meaning as a format field, the character is not formatted (for example, %% produces a single percent-sign character).

The format-control string is read from left to right. When the first format specification (if any) is encountered, it causes the value of the first argument after the format-control string to be converted and copied to the output buffer according to the format specification. If there are more arguments than format specifications, the extra arguments are ignored. If there are not enough arguments for all of the format specifications, the results are undefined.

A format specification has the following form:

%[-][#][0][width][.precision]type

Each field is a single character or a number signifying a particular format option. The type characters that appear after the last optional format field determine whether the associated argument is interpreted as a character, a string, or a number. The simplest format specification contains only the percent sign and a type character (for example, %s). The optional fields control other aspects of the formatting. The following lists the optional and required fields and their meanings:

Field Meaning
?/b> Pad the output with blanks or zeros to the right to fill the field width, justifying output to the left. If this field is omitted, the output is padded to the left, justifying it to the right.
# Prefix hexadecimal values with 0x (lowercase) or 0X (uppercase).
0 Pad the output value with zeros to fill the field width. If this field is omitted, the output value is padded with blank spaces.
width Copy the specified minimum number of characters to the output buffer. The width field is a nonnegative integer. The width specification never causes a value to be truncated; if the number of characters in the output value is greater than the specified width, or if the width field is not present, all characters of the value are printed, subject to the precision specification.
.precision For numbers, copy the specified minimum number of digits to the output buffer. If the number of digits in the argument is less than the specified precision, the output value is padded on the left with zeros. The value is not truncated when the number of digits exceeds the specified precision. If the specified precision is 0 or omitted entirely, or if the period (.) appears without a number following it, the precision is set to 1.
For strings, copy the specified maximum number of characters to the output buffer.
type Output the corresponding argument as a character, a string, or a number. This field can be any of the following character sequences:




Sequence Insert
C A single character.
d A signed decimal integer argument. This sequence is equivalent to the i sequence.
i A signed decimal integer. This sequence is equivalent to the d sequence.
ls, lS A string.
u An unsigned integer argument.
x, X An unsigned hexadecimal integer in lowercase or uppercase.

Return Value
Returns the formatted string.

Applies To
js

See Also
FormatCurrency, FormatDateTime, FormatNumber, FormatPercent

FormatCurrency, FormatDateTime, FormatNumber, FormatPercent

--------------------------------------------------------------------------------

Description
Formatting functions which match those of VBScript: Format, FormatCurrency?/span>, FormatDateTime?/span>, FormatNumber?/span>, FormatPercent?/span>. They require the newer OLE Automation binaries to be available. See Formatting for more information and example.

InvokeByRef

--------------------------------------------------------------------------------

Description
Allows JScript to call a method of an ActiveX object that takes a parameter by reference. See Invoke 'ByRef' for more information.

Syntax
value = js.InvokeByRef(object, method, argArray)

Parameter Description
object (Object) object on which to call the method
method (String) method to call
argArray (Array) JScript array of arguments

Return Value
Returns the same result as a direct object.method(...) call.

Example
// pack params to "args" array
args = new Array("msxml", 0, 0, 0, 0)

// call the "GetComponentVersion" method on "factory" object
factory.js.InvokeByRef(factory, "GetComponentVersion", args)

alert("MSXML Version: "+args[1]+"."+args[2]+"."+args[3]+"."+args[4])
Applies To
js

See Also
InvokeByRefResult

InvokeByRefResult

--------------------------------------------------------------------------------

Description
Allows JScript to call a method of an ActiveX object that takes a parameter by reference, and handle a possible failure case. See Invoke 'ByRef' for more information.

Syntax
error = js.InvokeByRefResult(object, method, argArray)

Parameter Description
object (Object) object on which to call the method
method (String) method to call
argArray (Array) JScript array of arguments

Return Value
Returns the error code number of an object.method(...) call. Zero means the call has succeeded. The invocation result value (if applicable) is available as argArray.value.

Example
// pack params to "args" array
args = new Array("msxml", 0, 0, 0, 0)

// call the "GetComponentVersion" method on "factory" object
error = factory.js.InvokeByRefResult(factory, "GetComponentVersion", args)

if ( error == 0 )
alert("MSXML Version: "+args[1]+"."+args[2]+"."+args[3]+"."+args[4])
else
alert("Error: "+error)
Applies To
js

See Also
InvokeByRef

MessageBeep

--------------------------------------------------------------------------------

Description
Plays a waveform sound. The waveform sound for each sound type is identified by an entry in the [sounds] section of the registry.

Syntax
factory.MessageBeep([type])

Parameter Description
type (Number) Specifies the sound type, as identified by an entry in the [sounds] section of the registry. This parameter can be one of the following values: Value Sound
-1 Standard beep using the computer speaker
0x00000040 SystemAsterisk
0x00000030 SystemExclamation
0x00000010 SystemHand
0x00000020 SystemQuestion
0x00000000 SystemDefault


Applies To
factory

See Also
MessageBox

MessageBox

--------------------------------------------------------------------------------

Description
Creates, displays, and operates a message box. The message box contains an application-defined message and title, plus any combination of predefined icons and push buttons.

Syntax
result = factory.MessageBeep(text[, caption[, type]])

Parameter Description
text (String) the message to display
caption (String) message box caption
type (Number) Specifies a set of bit flags that determine the contents and behavior of the dialog box. This parameter can be a combination of flags from the following groups of flags. Specify one of the following flags to indicate the buttons contained in the message box: Value Sound
0x00000000 The message box contains one push button: OK. This is the default
0x00000001 The message box contains two push buttons: OK and Cancel
0x00000004 The message box contains two push buttons: Yes and No
0x00000003 The message box contains three push buttons: Yes, No, and Cancel
0x00000030 An exclamation-point icon appears in the message box
0x00000040 An icon consisting of a lowercase letter i in a circle appears in the message box
0x00000010 A stop-sign icon appears in the message box
0x00010000 The message box becomes the foreground window
0x00040000 The message box is created as topmost window


Return Value
The return value is one of the following menu-item values:

Value Meaning
3 Abort button was selected.
2 Cancel button was selected.
7 No button was selected.
1 OK button was selected.
6 Yes button was selected.

Applies To
factory

See Also
MessageBeep

OnDocumentComplete

--------------------------------------------------------------------------------

Description
Notifies the caller about the HTML frame or window download completition.

Syntax
factory.OnDocumentComplete(frameOrWindow, callback)

Parameter Description
frameOrWindow (Object) frame or window object loading HTML content
callback (Object) refrences to JScript function object to be called upon download completition

Examples
var child = open("child.htm")
function onChildLoad() {
alert("Window loaded: "+child.document.title)
}
factory.OnDocumentComplete(child, onChildLoad)
Applies To
factory
孟子E章 2001-06-23
  • 打赏
  • 举报
回复
那个是外国的!
http://www.meadroid.com/scriptx/index/download.htm
andiyang 2001-06-23
  • 打赏
  • 举报
回复
多少钱
孟子E章 2001-06-23
  • 打赏
  • 举报
回复
那个方法免费的可以定制header,footer,margin,等,要是买的话,控制的内容就很多了 ,比如:打印机,纸张等!!
ie5.0SP1以上即可!
andiyang 2001-06-23
  • 打赏
  • 举报
回复
这个只能在Ie5。5上使用
而且我需要定制内容
孟子E章 2001-06-23
  • 打赏
  • 举报
回复
最好用插件了!
http://lucky.myrice.com/print.htm

87,920

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧