SGGL_SHJ/SGGL/FineUIPro.Web/AttachFile/officecontrol/index.js

116 lines
3.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var datatochildcmd = "";
var ntko;//控件对象
var savecode = "save.aspx";//保存文档程序程序
document.write("<script src='ntkoofficecontrol.min.js'></script>")
window.onbeforeunload = function (e) {
/*ntkocloseparentpage();*/
}
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
function openhtml(url) {
intializePage();
ntko = document.getElementById("TANGER_OCX");
if (window.navigator.platform == "Win32") {
ntko.AddDocTypePlugin(".pdf", "PDF.NtkoDocument", "4.0.1.0", "officecontrol/ntkooledocall.cab", 51, true);
}
if (window.navigator.platform == "Win64") {
ntko.AddDocTypePlugin(".pdf", "PDF.NtkoDocument", "4.0.1.0", "officecontrol/ntkooledocallx64.cab", 51, true);
}
if (url != '') {
ntko.OpenFromURL(url);
}
/*if (cmd == 1) {
ntko.OpenFromURL("ntkocreatnew.docx");
}
else {
ntko.OpenFromURL("aboutus.docx");
}*/
}
//保存office文档
function saveFileToUrl(url) {
var fileName = url;
/* if (fileName.length == 0) { alert("请输入文件标题!"); document.all("filetitle").focus(); return false; }//判断文件标题输入域
var result, filedot;
if (IsFileOpened) {
switch (ntko.doctype) {
case 1:
fileType = "Word.Document";
filedot = ".doc";
break;
case 2:
fileType = "Excel.Sheet";
filedot = ".xls";
break;
case 3:
fileType = "PowerPoint.Show";
filedot = ".ppt";
break;
case 4:
fileType = "Visio.Drawing";
filedot = ".vso"
break;
case 5:
fileType = "MSProject.Project";
filedot = ".pro";
break;
case 6:
fileType = "WPS Doc";
filedot = ".wps";
break;
case 7:
fileType = "Kingsoft Sheet";
filedot = ".et";
break;
default:
fileType = "unkownfiletype";
filedot = ".doc";
}*/
retHTML = ntko.saveToURL("save.aspx",//提交到的url地址
"EDITFILE",//文件域的id类似<input type=file id=upLoadFile 中的id
"savetype=1&fileType=Word.Document", //与控件一起提交的参数,savetype参数为要保存的文件格式office,html,pdf。filetype参数保存文件类型
fileName, //上传文件的名称,类似<input type=file 的value
0 //与控件一起提交的表单id也可以是form的序列号这里应该是0.
);
switch (ntko.StatusCode) {
case 0:
alert("文件保存成功");
ntko.ActiveDocument.Saved = true;
window.opener.location.reload();
var indexa = retHTML.indexOf("ID:");
var indexb = retHTML.indexOf("</br>");
var locationhref = retHTML.substring(indexa + 3, indexb);
window.location.href = editMScode + "?&url=" + locationhref;
break;
case 1:
erropen(retHTML);
break;
case 2:
erropen(retHTML);
break;
case 3:
erropen(retHTML);
break;
case 4:
erropen(retHTML);
break;
case 5:
erropen(retHTML);
break;
case 6:
erropen(retHTML);
break;
case 100:
erropen(retHTML);
break;
}
}