Home > Web Front-end > JS Tutorial > javascript OFFICE control test code_javascript skills

javascript OFFICE control test code_javascript skills

WBOY
Release: 2016-05-16 18:39:43
Original
1465 people have browsed it
Copy code 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 saving type
var TANGER_OCX_OBJ; //Control object
var TANGER_OCX_Username="Anonymous user";//User Name
var TANGER_OCX_key="";//Set the key to load 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: Create new; 2: Open for editing; 3: Open for reading
var TANGER_OCX_attachName; //Identifies the name of the existing online editing document attachment
var TANGER_OCX_attachURL; //The URL of the online editing document attachment
var TANGER_OCX_actionURL ; //The URL to which the form is submitted


//The current form cannot be edited, when the entire form is read-only, the
function is called FormDisabled(bool)
{
var formid=document .forms.item(0)
var elelength=formid.length;
for (var i=0; i{formid.elements[i].disabled = bool;}
//The following are the control title bar, status bar, toolbar, and menu bar that 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 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;
//Get the current operation code
TANGER_OCX_strOp = document.all.item(" TANGER_OCX_op").innerHTML;
//Get the existing attachment name
TANGER_OCX_attachName = document.all.item("TANGER_OCX_attachName").innerHTML;
//Get the 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 when the web page is loaded. Used to obtain the control object and save it to TANGER_OCX_OBJ
//At the same time, you can set the initial menu status, open the initial document, etc.
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;
//Get the current operation code
TANGER_OCX_strOp = document.all.item("TANGER_OCX_op").innerHTML;
//Get the existing attachment name
TANGER_OCX_attachName = document.all.item("TANGER_OCX_attachName") .innerHTML;
//Get the 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);//Parameters: URL, whether to display the process, whether to 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, at this time, TANGER_OCX_strOp specifies the url
//Use below The URL of the current document is used to obtain the URL of the template, which is the part following ?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 original form defines the OnSubmit event, save the document The original event will be called first.
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;
}
//Add demonstration custom menu item
function addMyMenuItems()
{
try{
TANGER_OCX_OBJ = document.all.item("TANGER_OCX");
//Add a custom file menu item
TANGER_OCX_OBJ.AddFileMenuItem('Save To the server - user-defined menu',false,true,1);
TANGER_OCX_OBJ.AddFileMenuItem('');
//Add a custom main menu item
TANGER_OCX_OBJ.AddCustomMenuItem('My menu 1 :Toggle prohibit copying',false,false,1);
TANGER_OCX_OBJ.AddCustomMenuItem('');
TANGER_OCX_OBJ.AddCustomMenuItem('My Menu 2',false,false,2);
TANGER_OCX_OBJ. AddCustomMenuItem('');
TANGER_OCX_OBJ.AddCustomMenuItem('My menu 3',false,false,3);
TANGER_OCX_OBJ.AddCustomMenuItem('');
TANGER_OCX_OBJ.AddCustomMenuItem('This menu needs to be opened ',false,true,4);
}
catch(err)
{
}
}
//This function is used to save the current document. The SaveToURL function of the control is mainly used.
//For detailed usage of this function, please refer to 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("No open document.");
return;
}
//The name of the attachment that needs to be deleted in the editing state
var deleteFile = "";
// Set the attachment file name to be saved
document.all.item("TANGER_OCX_filename").value = fileName;
switch(TANGER_OCX_strOp)
{
case "3":
alert(" The document is in reading status and you cannot save to the server.");
break;
case "2": //You need to delete the previous document attachment first
deleteFile = (TANGER_OCX_attachName=="")?"":"%�tach=" escape(TANGER_OCX_attachName );
case "1":
//New document
default:
retStr = TANGER_OCX_OBJ.SaveToURL(TANGER_OCX_actionURL,
document.all.item("NTKO_UPLOADFIELD").name, / /The name of the file upload control of 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, //The name of the file upload control of the subform
"%�tach=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.document;
newdoc.open ();
newdoc.write("

" retStr "
< ;/center>");
newdoc.close();
//window.alert(retStr);
window.opener.location.reload();
window.close();
break;
}
}
catch(err){
alert("Cannot save to URL:" err.number ":" err.description);
}
finally{
}
}

//This function is called when the document is opened.
function TANGER_OCX_OnDocumentOpened(str, obj)
{
try
{
TANGER_OCX_bDocOpen = true;
//设置用户名
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);//只读input元素失去焦点
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//上传文件名
);
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.document;
newdoc.open();
newdoc.write("

" retStr "
");
newdoc.close();
}
catch(err){
alert("不能保存到URL:" err.number ":" err.description);
}
finally{
}
}
//保存文档为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("不能保存到URL:" err.number ":" err.description);
}
finally{
}
}
//文档编辑页面关闭事件
function onPageClose()
{
if(IsFileOpened)
{
if(!TANGER_OCX_OBJ.ActiveDocument.Saved)
{
if(confirm( "文档修改过,还没有保存,是否需要保存?"))
{
TANGER_OCX_SaveDoc("newdoc.doc");
}
}
window.opener.location.reload();
}
}

//设置文件是打开还是关闭
function setFileOpenedOrClosed(bool)
{
IsFileOpened = bool;
fileType = TANGER_OCX_OBJ.DocType ;
}
function trim(str)
{ //删除左右两端的空格
return str.replace(/(^s*)|(s*$)/g, "");
}

//设置用户名
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.doctype==1||TANGER_OCX_OBJ.doctype==2)
{
try
{TANGER_OCX_OBJ.AddSecSignFromURL("ntko",signUrl);}
catch(error){}
}
else
{alert("不能在该类型文档中使用安全签名印章.");}
}
}
function addLocalSecSign()
{
if(IsFileOpened)
{
if(TANGER_OCX_OBJ.doctype==1||TANGER_OCX_OBJ.doctype==2)
{
try
{TANGER_OCX_OBJ.AddSecSignFromLocal("ntko","");}
catch(error){}
}
else
{alert("不能在该类型文档中使用安全签名印章.");}
}
}
function addEkeySecSign()
{
if(IsFileOpened)
{
if(TANGER_OCX_OBJ.doctype==1||TANGER_OCX_OBJ.doctype==2)
{
try
{TANGER_OCX_OBJ.AddSecSignFromEkey("ntko");}
catch(error){}
}
else
{alert("不能在该类型文档中使用安全签名印章.");}
}
}
function addHandSecSign()
{
if(IsFileOpened)
{
if(TANGER_OCX_OBJ.doctype==1||TANGER_OCX_OBJ.doctype==2)
{
try
{TANGER_OCX_OBJ.AddSecHandSign("ntko");}
catch(error){}
}
else
{alert("不能在该类型文档中使用安全签名印章.");}
}
}

function addServerSign(signUrl)
{
if(IsFileOpened)
{
try
{
TANGER_OCX_OBJ.AddSignFromURL("ntko",//印章的用户名
signUrl,//印章所在服务器相对url
100,//左边距
100,//上边距 根据Relative的设定选择不同参照对象
"ntko",//调用DoCheckSign函数签名印章信息,用来验证印章的字符串
3, //Relative,取值1-4。Set the left margin and top margin relative to the position of the following objects 1: cursor position; 2: page margin; 3: page distance 4: default setting bar, paragraph
100, // scaling seal, default 100%
1); //0 seal is below the text, 1 is above the text

}
catch(error){}
}
}

function addLocalSign()
{
if(IsFileOpened)
{
try
{
TANGER_OCX_OBJ.AddSignFromLocal("ntko",//The user name of the seal
"",//The default file name
true, //Whether you are prompted to select
100, //Left margin
100, //The top margin selects different reference objects according to the setting of Relative
"ntko", //Call the DoCheckSign function signature Seal information, a string used to verify the seal
3, //Relative, value 1-4. Set the left margin and top margin relative to the position of the following objects: 1: Cursor position; 2: Page margin; 3: Page distance 4: Default settings column, paragraph
100, //Scale seal, default 100%
1); //0 seal is below the text, 1 is above the text
}
catch(error) {}
}
}
function addPicFromUrl(picURL)
{
if(IsFileOpened)
{
if(TANGER_OCX_OBJ.doctype==1||TANGER_OCX_OBJ.doctype= =2)
{
try
{
TANGER_OCX_OBJ.AddPicFromURL(picURL, //The url address of the picture can be a relative or absolute address
false, //Whether it is floating, this parameter is set to When false, top and left are invalid
100, //left left margin
100, //top top margin selects different reference objects according to the setting of Relative
1, //Relative, value 1-4 . Set the left margin and top margin relative to the position of the following objects: 1: cursor position; 2: page margin; 3: page distance 4: default setting bar, paragraph
100, // scaling seal, default 100%
1); //0 seal is below the text, 1 is above

}
catch(error){}
}
else
{alert("Cannot be used in this type Use a secure signature seal in the document.");}
}
}
function addPicFromLocal()
{
if(IsFileOpened)
{
try
{
TANGER_OCX_OBJ.AddPicFromLocal("",//User name of stamp
true,//Default file name
false,//Whether to prompt to select
100,//Left margin
100, //The top margin selects different reference objects according to the setting of Relative
1, //Relative, the value is 1-4. Set the left margin and top margin relative to the position of the following objects 1: cursor position; 2: page margin; 3: page distance 4: default setting bar, paragraph
100, // scaling seal, default 100%
1); //0 seal is below the text, 1 is above
}
catch(error){}
}
}

function TANGER_OCX_AddDocHeader(strHeader)
{
if(!IsFileOpened)
{return;}
var i,cNum = 30;
var lineStr = "";
try
{
for(i=0 ;iwith(TANGER_OCX_OBJ.ActiveDocument.Application)
{
Selection.HomeKey(6,0); // go home
Selection.TypeText(strHeader);
Selection.TypeParagraph(); //Line break
Selection.TypeText(lineStr); //Insert underline
// Selection.InsertSymbol(95,"",true) ; //Insert underline
Selection.TypeText("★");
Selection.TypeText(lineStr); //Insert underline
Selection.TypeParagraph();
//Selection.MoveUp(5 , 2, 1); //Move up two lines and hold down the Shift key, which is equivalent to selecting two lines
Selection.HomeKey(6,1); //Select all text to the beginning of the file
Selection. ParagraphFormat.Alignment = 1; //Centered 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; = false;
Subscript = false;
Spacing = 0;
Scaling = 100;
Position = 0;
Kerning = 0;
Animation = 0;
DisableCharacterSpaceGrid = false;
EmphasisMark = 0;
}
Selection.MoveDown(5, 3, 0); //Move down 3 lines
}
}
catch(err){
alert("Error:" err.number ":" err.description);
}
finally{
}
}

function insertRedHeadFromUrl(headFileURL)
{
if(TANGER_OCX_OBJ.doctype!=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 the red head document at the cursor position
}
function openTemplateFileFromUrl(templateUrl)
{
TANGER_OCX_OBJ.openFromUrl(templateUrl);
}
function doHandSign()
{
/*if(TANGER_OCX_OBJ.doctype==1||TANGER_OCX_OBJ.doctype==2)//The setting here only allows stamping in word and excel .doctype=1 is a "word" document, doctype=2 is an "excel" document
{*/
TANGER_OCX_OBJ.DoHandSign2(
"ntko",//Handwritten signature user name
"ntko" ,//signkey, the verification key required by DoCheckSign (check seal function).
0,//left
0,//top
1,//relative, set the reference object of the signature position. 0: means inserting according to the screen position. At this time, the Left and Top attributes are not available effect.1: Cursor position; 2: Page margin; 3: Page distance 4: Default setting column, paragraph (for compatibility with previous version default method)
100);
//}
}
function SetReviewMode(boolvalue)
{
if(TANGER_OCX_OBJ.doctype==1)
{
TANGER_OCX_OBJ.ActiveDocument.TrackRevisions = boolvalue;//Set whether to retain traces
}
}

function setShowRevisions(boolevalue)
{
if(TANGER_OCX_OBJ.doctype==1)
{
TANGER_OCX_OBJ.ActiveDocument.ShowRevisions =boolevalue;//Set 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 printing is allowed
}
function setFileNew(boolvalue)
{
TANGER_OCX_OBJ.FileNew=boolvalue;/ /Whether new creation is allowed
}
function setFileSaveAs(boolvalue)
{
TANGER_OCX_OBJ.FileSaveAs=boolvalue;//Whether saving as is allowed
}

function setIsNoCopy(boolvalue)
{
TANGER_OCX_OBJ.IsNoCopy=boolvalue;//Whether pasting is prohibited
}
function DoCheckSign()
{
if(IsFileOpened)
{
var ret = TANGER_OCX_OBJ.DoCheckSign
(
false,/*The optional parameter IsSilent defaults to FAlSE, which means the verification dialog box pops up, otherwise, just returns the verification result to the return value*/
"ntko"//Use cover Chapter signkey, here 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 submenu item
for(var subsubmenuPos=0;subsubmenuPos<3;subsubmenuPos)
{
if(0 ==subsubmenuPos)//Add submenu item
{
myobj.AddCustomMenuItem2 (menuPos,submenuPos,subsubmenuPos,false,
"Set printing area",false,menuPos*100 submenuPos*20 subsubmenuPos);
}
if(1 ==subsubmenuPos)//Add submenu 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 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 submenu item
for(var subsubmenuPos=0;subsubmenuPos<2;subsubmenuPos)
{
if(0 ==subsubmenuPos)//Add submenu item
{
myobj.AddCustomMenuItem2(menuPos,submenuPos,subsubmenuPos,false,
"View the entire web page",false,menuPos* 100 submenuPos*20 subsubmenuPos);
}
if(1 ==subsubmenuPos)//Add submenu item
{
myobj.AddCustomMenuItem2(menuPos,submenuPos,subsubmenuPos,false,
" Restore original size",false,menuPos*100 submenuPos*20 subsubmenuPos);
}
}
}
}
}
//Change the size of the control to the visible area of ​​the current web page
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;//The width of the visible area of ​​the web page
document.all.officecontrol.style.height=document .body.clientHeight;//The visible area of ​​the web page 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";
}
//显示或隐藏文档控件对象
function ObjectDisplay(boolvalue)
{
var obj=document.getElementById("objside");
if(!boolvalue)
{
obj.style.display="none";
}
else
{
obj.style.display="block";
}
}

/**
* Formatting of time objects;
*/
Date.prototype.format = function(format){
/*
* eg:format="YYYY-MM-dd hh:mm:ss";
*/
var o = {
"Y ":this.getYear(),//年
"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 labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template