JavascriptOFFICE control test code _ javascript skills

Source: Internet
Author: User
The OFFICE control test code mainly controls some office functions. For more information, see. The Code is as follows:


// The following variables are JS public variables.
Var TANGER_OCX_bDocOpen = false;
Var TANGER_OCX_filename; // file name
Var filetype = ""; // file type
Var savetype; // file storage type
Var TANGER_OCX_OBJ; // control object
Var TANGER_OCX_Username = "anonymous User"; // User Name
Var TANGER_OCX_key = ""; // you can specify the key for loading the seal.
Var IsFileOpened; // whether the control opens the document
Var svisble = true; // seal display status
Var TANGER_OCX_strOp; // identifies the current operation. 1: New; 2: Open edit; 3: open read
Var TANGER_OCX_attachName; // identifies the name of an existing online editing document attachment.
Var TANGER_OCX_attachURL; // URL of the online editing document attachment
Var TANGER_OCX_actionURL; // URL to which the form is submitted


// The current form cannot be edited. It is called when the entire form is read-only.
Function FormDisabled (bool)
{
Var formid = document. forms. item (0)
Var elength = formid. length;
For (var I = 0; I {Formid. elements [I]. disabled = bool ;}
// The control title bar, status bar, toolbar, and menu bar are not displayed.
TANGER_OCX_OBJ.TitleBar =! Bool;
TANGER_OCX_OBJ.Statusbar =! Bool;
TANGER_OCX_OBJ.ToolBars =! Bool;
TANGER_OCX_OBJ.Menubar =! Bool;
}
// Sample program help document
Function NtkoHelp ()
{
Window. open ("help.htm", "help ");
}
// Open the document window
Function popupDocWin (turl ){
Var aw = window. screen. availWidth;
Var ah = window. screen. availHeight;
Window. open (turl, "office ");
}
// Create a document
Function CreatNew (DocType)
{
TANGER_OCX_OBJ = document. all. item ("TANGER_OCX ");
TANGER_OCX_OBJ.CreateNew (DocType );
Var useUTF8 = (document. charset = "UTF-8 ");
TANGER_OCX_OBJ.IsUseUTF8Data = useUTF8;
Try
{
// Save the submission url of the form and pass it to the SaveToURL function of the control in the future.
TANGER_OCX_actionURL = document. forms [0]. action;
// Obtain the current operation code
TANGER_OCX_strOp = document. all. item ("TANGER_OCX_op"). innerHTML;
// Obtain the name of an existing attachment
TANGER_OCX_attachName = document. all. item ("TANGER_OCX_attachName"). innerHTML;
// Obtain an existing attachment URL
TANGER_OCX_attachURL = document. all. item ("TANGER_OCX_attachURL"). innerHTML;
TANGER_OCX_key = document. all. item ("TANGER_OCX_key"). innerHTML;
} Catch (err) {} finally {};
}
// This function is called during webpage loading. Used to obtain control objects and save them to TANGER_OCX_OBJ.
// You can also set the initial menu conditions and open the initial document.
Function TANGER_OCX_Init (initdocurl)
{
TANGER_OCX_OBJ = document. all. item ("TANGER_OCX ");
Var useUTF8 = (document. charset = "UTF-8 ");
TANGER_OCX_OBJ.IsUseUTF8Data = useUTF8;
Try
{
// Save the submission url of the form and pass it to the SaveToURL function of the control in the future.
TANGER_OCX_actionURL = document. forms [0]. action;
// Obtain the current operation code
TANGER_OCX_strOp = document. all. item ("TANGER_OCX_op"). innerHTML;
// Obtain the name of an existing attachment
TANGER_OCX_attachName = document. all. item ("TANGER_OCX_attachName"). innerHTML;
// Obtain an existing attachment URL
TANGER_OCX_attachURL = document. all. item ("TANGER_OCX_attachURL"). innerHTML;
Try {
TANGER_OCX_key = document. all. item ("TANGER_OCX_key"). innerHTML;
} Catch (err) {} finally {};
TANGER_OCX_OBJ.SetAutoCheckSignKey (TANGER_OCX_key );
Switch (TANGER_OCX_strOp)
{
Case "1 ":
If (initdocurl! = "")
{
TANGER_OCX_OBJ.BeginOpenFromURL (initdocurl, true, false); // parameter: URL, display process, read-only
}
Break;
Case "2 ":
If (TANGER_OCX_attachURL)
{
TANGER_OCX_OBJ.BeginOpenFromURL (TANGER_OCX_attachURL, true, false );
}
Else
{
If (initdocurl! = "")
TANGER_OCX_OBJ.BeginOpenFromURL (initdocurl, true, false );
}
Break;
Case "3 ":
If (TANGER_OCX_attachURL)
{
TANGER_OCX_OBJ.BeginOpenFromURL (TANGER_OCX_attachURL, true, true );
}
Break;
Default: // to open the specified template file, TANGER_OCX_strOp specifies the url
// Use the URL of the current document to obtain the template URL, that is? Parts after openform
Var keystr = "? Openform & ". toUpperCase ();
Var parastring = window. location. search;
// Alert (parastring );
Var urlbegin = parastring. toUpperCase (). indexOf (keystr );
If (-1! = Urlbegin)
{
TANGER_OCX_strOp = parastring. substr (urlbegin + keystr. length );
// Alert (TANGER_OCX_strOp );
// Determine whether it is a WPS Template
Var wpsKey = "vwWpsTurl". toUpperCase ();
Var isWpsTemplateURL = (-1! = Parastring. toUpperCase (). indexOf (wpsKey ));
If (! IsWpsTemplateURL)
{
TANGER_OCX_OBJ.BeginOpenFromURL (TANGER_OCX_strOp, true, false );
}
Else
{
TANGER_OCX_OBJ.BeginOpenFromURL (TANGER_OCX_strOp, true, false, "WPS. Document ");
}
}
Break;
}
}
Catch (err ){
Alert ("error:" + err. number + ":" + err. description );
}
Finally {
}
}
// If the previous form defines an OnSubmit event, the original event will be called first when saving the document.
Function TANGER_OCX_doFormOnSubmit ()
{
Var form = document. forms [0];
If (form. onsubmit)
{
Var retVal = form. onsubmit ();
If (typeof retVal = "boolean" & retVal = false)
Return false;
}
Return true;
}
// Added a custom menu item for demonstration.
Function addMyMenuItems ()
{
Try {
TANGER_OCX_OBJ = document. all. item ("TANGER_OCX ");
// Add a menu item for the custom file
TANGER_OCX_OBJ.AddFileMenuItem ('Save to server-User-Defined menu ', false, true, 1 );
TANGER_OCX_OBJ.AddFileMenuItem ('');
// Add a custom main menu item
TANGER_OCX_OBJ.AddCustomMenuItem ('My menu 1: Disable copying; ', false, false, 1 );
Tanger_ocx_obj.addmmmmenuitem ('');
TANGER_OCX_OBJ.AddCustomMenuItem ('My menu 2', false, false, 2 );
Tanger_ocx_obj.addmmmmenuitem ('');
TANGER_OCX_OBJ.AddCustomMenuItem ('My menu 3', false, false, 3 );
Tanger_ocx_obj.addmmmmenuitem ('');
TANGER_OCX_OBJ.AddCustomMenuItem ('the document to be opened in this menu can be used ', false, true, 4 );
}
Catch (err)
{
}
}
// This function is used to save the current document. The SaveToURL function of the control is used.
// For detailed usage of this function, see the Programming Manual.
Function TANGER_OCX_SaveDoc (fileName)
{
Var retStr = new String;
Var newwin, newdoc;
If (fileName = "")
{
Alert ("Please specify the attachment name! ");
Return;
}
Try
{
If (! TANGER_OCX_doFormOnSubmit () return;
If (! TANGER_OCX_bDocOpen)
{
Alert ("the document is not open. ");
Return;
}
// The Name Of The attachment to be deleted in the editing status
Var deleteFile = "";
// Set the file name of the attachment to be saved
Document. all. item ("TANGER_OCX_filename"). value = fileName;
Switch (TANGER_OCX_strOp)
{
Case "3 ":
Alert ("the document is read and cannot be saved to the server. ");
Break;
Case "2": // Delete the attachment of the previous document first
DeleteFile = (TANGER_OCX_attachName = "")? "": "% Detach =" + escape (TANGER_OCX_attachName );
Case "1 ":
// Create a document
Default:
RetStr = TANGER_OCX_OBJ.SaveToURL (TANGER_OCX_actionURL,
Document. all. item ("NTKO_UPLOADFIELD"). name, // name of the file upload control in the subform
DeleteFile,
FileName,
0 // submit the information of forms [0] at the same time
);
RetMhtStr = TANGER_OCX_OBJ.SaveAsOtherFormatToURL (
1,
TANGER_OCX_actionURL,
Document. all. item ("NTKO_UPLOADFIELD"). name, // name of the file upload control in the subform
"% Detach = newdoc. mht ",
"Newdoc. mht ",
0 // submit the information of forms [0] at the same time
);
Newwin = window. open ("", "_ blank", "left = 200, top = 200, width = 400, height = 200, status = 0, toolbar = 0, menubar = 0, location = 0, scrollbars = 0, resizable = 0 ", false );
Newdoc = newwin.doc ument;
Newdoc. open ();
Newdoc. write ("

"+ RetStr +" ");
Newdoc. close ();
// Window. alert (retStr );
Window. opener. location. reload ();
Window. close ();
Break;
}
}
Catch (err ){
Alert ("cannot be saved to URL:" + err. number + ":" + err. description );
}
Finally {
}
}

// This function is called when the document is opened.
Function tanger_ocx_on1_entopened (str, obj)
{
Try
{
TANGER_OCX_bDocOpen = true;
// Set the user name
TANGER_OCX_SetDocUser (TANGER_OCX_Username );
If (obj)
{
Switch (TANGER_OCX_strOp)
{
Case "1 ":
Case "2 ":
TANGER_OCX_OBJ.SetReadOnly (false );
Break;
Case "3 ":
TANGER_OCX_OBJ.SetReadOnly (true );
FormDisabled (true); // the read-only input element loses focus
Break;
Default:
Break;
}
}
}
Catch (err ){

}
Finally {
}
}
Function SaveAsHTML (URL, uploadfield, fileName)
{
Try
{
Var retStr = TANGER_OCX_OBJ.PublishAsHTMLToURL (
URL, uploadfield, "_ Click = 0 & filetitle =" + escape (document. forms (0). filetitle. value) +
"& Fileother =" + escape (document. forms (0). fileother. value) +
"& Fileid =" + escape (document. forms (0). fileid. value) +
"& Filename =" + fileName,
FileName // Upload File Name
);
Var newwin = window. open ("", "_ blank", "left = 200, top = 200, width = 400, height = 200, status = 0, toolbar = 0, menubar = 0, location = 0, scrollbars = 0, resizable = 0 ", false );
Var newdoc = newwin.doc ument;
Newdoc. open ();
Newdoc. write (" "+ RetStr +" ");
Newdoc. close ();
}
Catch (err ){
Alert ("cannot be saved to URL:" + err. number + ":" + err. description );
}
Finally {
}
}
// Save the document as pdf
Function saveFileAsPdfToUrl (URL, uploadfield, fileName)
{
Try
{
Var retStr = TANGER_OCX_OBJ.PublishAsPDFToURL (
URL, uploadfield, "_ Click = 0 & filename =" + fileName +
"& Filetitle =" + document. all ("filetitle"). value +
"& Fileother =" + document. all ("fileother"). value +
"& Fileid =" + document. all ("fileid"). value,
FileName,
"",
Null,
True,
False,
False,
Null,
False,
True
);
}
Catch (err ){
Alert ("cannot be saved to URL:" + err. number + ":" + err. description );
}
Finally {
}
}
// Close the event on the document editing page
Function onPageClose ()
{
If (IsFileOpened)
{
If (! TANGER_OCX_OBJ.ActiveDocument.Saved)
{
If (confirm ("the document has been modified and has not been saved. Do you want to save it? "))
{
TANGER_OCX_SaveDoc ("newdoc.doc ");
}
}
Window. opener. location. reload ();
}
}

// Set whether to open or close the file
Function setFileOpenedOrClosed (bool)
{
IsFileOpened = bool;
FileType = TANGER_OCX_OBJ.DocType;
}
Function trim (str)
{// Delete spaces between the left and right sides
Return str. replace (/(^ \ s *) | (\ s * $)/g ,"");
}

// Set the user name
Function TANGER_OCX_SetDocUser (cuser)
{
With (TANGER_OCX_OBJ.ActiveDocument.Application)
{
UserName = cuser;
UserInitials = cuser;
}
}
Function addServerSecSign ()
{
Var signUrl = document. all ("secSignFileUrl"). options [document. all ("secSignFileUrl"). selectedIndex]. value;
If (IsFileOpened)
{
If(TANGER_OCX_OBJ.doc type = 1 | TANGER_OCX_OBJ.doctype = 2)
{
Try
{TANGER_OCX_OBJ.AddSecSignFromURL ("ntko", signUrl );}
Catch (error ){}
}
Else
{Alert ("Security signature seal cannot be used in this type of document .");}
}
}
Function addLocalSecSign ()
{
If (IsFileOpened)
{
If(TANGER_OCX_OBJ.doc type = 1 | TANGER_OCX_OBJ.doctype = 2)
{
Try
{TANGER_OCX_OBJ.AddSecSignFromLocal ("ntko ","");}
Catch (error ){}
}
Else
{Alert ("Security signature seal cannot be used in this type of document .");}
}
}
Function addEkeySecSign ()
{
If (IsFileOpened)
{
If(TANGER_OCX_OBJ.doc type = 1 | TANGER_OCX_OBJ.doctype = 2)
{
Try
{TANGER_OCX_OBJ.AddSecSignFromEkey ("ntko ");}
Catch (error ){}
}
Else
{Alert ("Security signature seal cannot be used in this type of document .");}
}
}
Function addHandSecSign ()
{
If (IsFileOpened)
{
If(TANGER_OCX_OBJ.doc type = 1 | TANGER_OCX_OBJ.doctype = 2)
{
Try
{TANGER_OCX_OBJ.AddSecHandSign ("ntko ");}
Catch (error ){}
}
Else
{Alert ("Security signature seal cannot be used in this type of document .");}
}
}

Function addServerSign (signUrl)
{
If (IsFileOpened)
{
Try
{
TANGER_OCX_OBJ.AddSignFromURL ("ntko", // User Name of the Seal
SignUrl, // relative url of the server where the seal is located
100, // left margin
100, // The top margin selects different reference objects based on Relative settings
"Ntko", // call the DoCheckSign function signature stamp information to verify the seal string
3, // Relative, value range: 1-4. Set the position of the left margin and top margin relative to the following object: 1: cursor position; 2: margin; 3: Page distance 4: default setting bar, paragraph
100, // zoom stamp, default 100%
1); // 0. The stamp is under the text, and 1 is above

}
Catch (error ){}
}
}

Function addLocalSign ()
{
If (IsFileOpened)
{
Try
{
TANGER_OCX_OBJ.AddSignFromLocal ("ntko", // User Name of the Seal
"", // Default file name
True, // whether to prompt for selection
100, // left margin
100, // The top margin selects different reference objects based on Relative settings
"Ntko", // call the DoCheckSign function signature stamp information to verify the seal string
3, // Relative, value range: 1-4. Set the position of the left margin and top margin relative to the following object: 1: cursor position; 2: margin; 3: Page distance 4: default setting bar, paragraph
100, // zoom stamp, default 100%
1); // 0. The stamp is under the text, and 1 is above
}
Catch (error ){}
}
}
Function addPicFromUrl (picURL)
{
If (IsFileOpened)
{
If(TANGER_OCX_OBJ.doc type = 1 | TANGER_OCX_OBJ.doctype = 2)
{
Try
{
TANGER_OCX_OBJ.AddPicFromURL (picURL, // the url of the image can be relative or absolute.
False, // whether it is floating. If this parameter is set to false, the top and left are invalid.
100, // left margin
100, // top margin select different reference objects based on Relative settings
1, // Relative, value range: 1-4. Set the position of the left margin and top margin relative to the following object: 1: cursor position; 2: margin; 3: Page distance 4: default setting bar, paragraph
100, // zoom stamp, default 100%
1); // 0. The stamp is under the text, and 1 is above

}
Catch (error ){}
}
Else
{Alert ("Security signature seal cannot be used in this type of document .");}
}
}
Function addPicFromLocal ()
{
If (IsFileOpened)
{
Try
{
TANGER_OCX_OBJ.AddPicFromLocal ("", // User Name of the Seal
True, // default file name
False, // whether to prompt for selection
100, // left margin
100, // The top margin selects different reference objects based on Relative settings
1, // Relative, value range: 1-4. Set the position of the left margin and top margin relative to the following object: 1: cursor position; 2: margin; 3: Page distance 4: default setting bar, paragraph
100, // zoom stamp, default 100%
1); // 0. The stamp is under the text, and 1 is above
}
Catch (error ){}
}
}

Function TANGER_OCX_AddDocHeader (strHeader)
{
If (! IsFileOpened)
{Return ;}
Var I, cNum = 30;
Var lineStr = "";
Try
{
For (I = 0; I With (TANGER_OCX_OBJ.ActiveDocument.Application)
{
Selection. HomeKey (6, 0); // go home
Selection. TypeText (strHeader );
Selection. TypeParagraph (); // line feed
Selection. TypeText (lineStr); // insert an underline
// Selection. InsertSymbol (95, "", true); // insert an underline
Selection. TypeText ("★");
Selection. TypeText (lineStr); // insert an underline
Selection. TypeParagraph ();
// Selection. MoveUp (5, 2, 1); // move two rows up and hold down the Shift key, which is equivalent to selecting two rows
Selection. HomeKey (6, 1); // select all text in the file header
Selection. ParagraphFormat. Alignment = 1; // center Alignment
With (Selection. Font)
{
NameFarEast = "";
Name = "";
Size = 12;
Bold = false;
Italic = false;
Underline = 0;
UnderlineColor = 0;
StrikeThrough = false;
DoubleStrikeThrough = false;
Outline = false;
Emboss = false;
Shadow = false;
Hidden = false;
SmallCaps = false;
AllCaps = false;
Color = 255;
Engrave = false;
Superscript = false;
Subscript = false;
Spacing = 0;
Scaling= 100;
Position = 0;
Kerning = 0;
Animation = 0;
DisableCharacterSpaceGrid = false;
EmphasisMark = 0;
}
Selection. MoveDown (5, 3, 0); // move three rows down
}
}
Catch (err ){
Alert ("error:" + err. number + ":" + err. description );
}
Finally {
}
}

Function insertRedHeadFromUrl (headFileURL)
{
If(TANGER_OCX_OBJ.doc type! = 1) // TANGER_OCX_OBJ.doctype = 1 is a Word document
{Return ;}
TANGER_OCX_OBJ.ActiveDocument.Application.Selection.HomeKey (6, 0); // move the cursor to the beginning of the document
TANGER_OCX_OBJ.addtemplatefromurl (headFileURL); // insert a red header document at the cursor position
}
Function openTemplateFileFromUrl (templateUrl)
{
TANGER_OCX_OBJ.openFromUrl (templateUrl );
}
Function doHandSign ()
{
/* If(TANGER_OCX_OBJ.doc type = 1 | TANGER_OCX_OBJ.doctype = 2) // define type = 1 is a "word" document, doctype = 2 is a "excel" Document
{*/
TANGER_OCX_OBJ.DoHandSign2 (
"Ntko", // handwritten signature User Name
"Ntko", // The verification key required by signkey and DoCheckSign (checking the seal function.
0, // left
0, // top
1, // relative, set the reference object for the signature position. 0: indicates that the object is inserted according to the screen position. At this time, the Left and Top attributes do not work. 1: cursor position; 2: margin; 3: Page distance 4: default setting column and section (compatible with the default mode of previous versions)
100 );
//}
}
Function SetReviewMode (boolvalue)
{
If(TANGER_OCX_OBJ.doc type = 1)
{
TANGER_OCX_OBJ.ActiveDocument.TrackRevisions = boolvalue; // you can specify whether to retain traces.
}
}

Function setShowRevisions (boolevalue)
{
If(TANGER_OCX_OBJ.doc type = 1)
{
TANGER_OCX_OBJ.ActiveDocument.ShowRevisions = boolevalue; // you can specify whether to display traces.
}
}
// Accept or cancel all revisions
Function TANGER_OCX_AllRevisions (bool)
{
If (bool)
{
TANGER_OCX_OBJ.ActiveDocument.AcceptAllRevisions (); // accept all trace revisions
}
Else
{
TANGER_OCX_OBJ.ActiveDocument.Application.WordBasic.RejectAllChangesInDoc (); // reject all trace revisions
}
}
Function setFilePrint (boolvalue)
{
TANGER_OCX_OBJ.fileprint = boolvalue; // whether to allow printing
}
Function setFileNew (boolvalue)
{
TANGER_OCX_OBJ.FileNew = boolvalue; // whether to allow new
}
Function setFileSaveAs (boolvalue)
{
TANGER_OCX_OBJ.FileSaveAs = boolvalue; // whether to allow saving
}

Function setIsNoCopy (boolvalue)
{
TANGER_OCX_OBJ.IsNoCopy = boolvalue; // whether to disable pasting
}
Function DoCheckSign ()
{
If (IsFileOpened)
{
Var ret = TANGER_OCX_OBJ.DoCheckSign
(
False,/* the optional parameter IsSilent defaults to FAlSE, indicating that the verification dialog box is displayed. Otherwise, only the return value of the verification result is returned */
"Ntko" // use the signkey when stamping. Here it is "ntko"
); // Return value, verification result string
// Alert (ret );
}
}
Function setToolBar ()
{
TANGER_OCX_OBJ.ToolBars =! TANGER_OCX_OBJ.ToolBars;
}
Function setMenubar ()
{
TANGER_OCX_OBJ.Menubar =! TANGER_OCX_OBJ.Menubar;
}
Function setInsertMemu ()
{
TANGER_OCX_OBJ.IsShowInsertMenu =! TANGER_OCX_OBJ.IsShowInsertMenu;
}
Function setEditMenu ()
{
TANGER_OCX_OBJ.IsShowEditMenu =! TANGER_OCX_OBJ.IsShowEditMenu;
}
Function setToolMenu ()
{
TANGER_OCX_OBJ.IsShowToolMenu =! TANGER_OCX_OBJ.IsShowToolMenu;
}

// Add a custom menu
Function initCustomMenus1 ()
{
Var myobj = TANGER_OCX_OBJ;
For (var menuPos = 0; menuPos <1; menuPos ++)
{
Myobj. AddCustomMenu2 (menuPos, "common functions" + "(&" + menuPos + ")");
For (var submenuPos = 0; submenuPos <1; submenuPos ++)
{
Myobj. AddCustomMenuItem2 (menuPos, submenuPos,-1, true, "Print Settings", false );
// Add a sub-menu item
For (var subsubmenuPos = 0; subsubmenuPos <3; subsubmenuPos ++)
{
If (0 = submenupos) // Add a sub-menu item
{
Myobj. AddCustomMenuItem2 (menuPos, submenuPos, subsubmenuPos, false,
"Set the print area", false, menuPos * 100 + submenuPos * 20 + subsubmenuPos );
}
If (1 = submenupos) // Add a sub-menu item
{
Myobj. AddCustomMenuItem2 (menuPos, submenuPos, subsubmenuPos, false,
"Cancel printing area", false, menuPos * 100 + submenuPos * 20 + subsubmenuPos );
}
If (2 = subsubmenuPos)
{
Myobj. AddCustomMenuItem2 (menuPos, submenuPos, subsubmenuPos, false,
"Handwritten annotation", false, menuPos * 100 + submenuPos * 20 + subsubmenuPos );
}
}
}
}
}
// Control
Function controlStyle ()
{
Var myobj = TANGER_OCX_OBJ;
For (var menuPos = 0; menuPos <1; menuPos ++)
{
Myobj. AddCustomMenu2 (menuPos, "control style" + "(&" + menuPos + ")");
For (var submenuPos = 0; submenuPos <1; submenuPos ++)
{
Myobj. AddCustomMenuItem2 (menuPos, submenuPos,-1, true, "change size", false );
// Add a sub-menu item
For (var subsubmenuPos = 0; subsubmenuPos <2; subsubmenuPos ++)
{
If (0 = submenupos) // Add a sub-menu item
{
Myobj. AddCustomMenuItem2 (menuPos, submenuPos, subsubmenuPos, false,
"View all webpages", false, menuPos * 100 + submenuPos * 20 + subsubmenuPos );
}
If (1 = submenupos) // Add a sub-menu item
{
Myobj. AddCustomMenuItem2 (menuPos, submenuPos, subsubmenuPos, false,
"Restore original size", false, menuPos * 100 + submenuPos * 20 + subsubmenuPos );
}
}
}
}
}
// Change the widget size to the visible area of the current webpage.
Function objside ()
{
Document. all. officecontrol. style. position = "absolute ";
Document. all. officecontrol. style. left = "0px ";
Document. all. officecontrol. style. top = "0px ";
Document. all. officecontrol. style. width = document. body. clientWidth; // visible area width of the webpage
Document. all. officecontrol. style. height = document. body. clientHeight; // The visible area of the webpage is high.
}
// Restore the display size of the control.
Function objside2 ()
{
Document. all. officecontrol. style. position = "relative ";
Document. all. officecontrol. style. left = "0px ";
Document. all. officecontrol. style. top = "0px ";
Document. all. officecontrol. style. width = "100% ";
Document. all. officecontrol. style. height = "980px ";
}
// Display or hide a document control object
Function ObjectDisplay (boolvalue)
{
Var obj = document. getElementById ("objside ");
If (! Boolvalue)
{
Obj. style. display = "none ";
}
Else
{
Obj. style. display = "block ";
}
}

/**
* Format the time object;
*/
Date. prototype. format = function (format ){
/*
* Eg: format = "YYYY-MM-dd hh: mm: ss ";
*/
Var o = {
"Y +": this. getYear (), // year
"M +": this. getMonth () + 1, // month
"D +": this. getDate (), // day
"H +": this. getHours (), // hour
"M +": this. getMinutes (), // minute
"S +": this. getSeconds (), // second
"Q +": Math. floor (this. getMonth () + 3)/3), // quarter
"S": this. getMilliseconds () // millisecond
}

If (/(y +)/. test (format )){
Format = format. replace (RegExp. $1, (this. getFullYear () + ""). substr (4-RegExp. $1. length ));
}

For (var k in o ){
If (new RegExp ("(" + k + ")"). test (format )){
Format = format. replace (RegExp. $1, RegExp. $1. length = 1? O [k]: ("00" + o [k]). substr ("" + o [k]). length ));
}
}
Return format;
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.