ntkoofficecontrol.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. 
  2. // 请勿修改,否则可能出错
  3. var userAgent = navigator.userAgent,
  4. rMsie = /(msie\s|trident.*rv:)([\w.]+)/,
  5. rFirefox = /(firefox)\/([\w.]+)/,
  6. rOpera = /(opera).+version\/([\w.]+)/,
  7. rChrome = /(chrome)\/([\w.]+)/,
  8. rSafari = /version\/([\w.]+).*(safari)/;
  9. var browser;
  10. var version;
  11. var ua = userAgent.toLowerCase();
  12. function uaMatch(ua) {
  13. var match = rMsie.exec(ua);
  14. if (match != null) {
  15. return { browser : "IE", version : match[2] || "0" };
  16. }
  17. var match = rFirefox.exec(ua);
  18. if (match != null) {
  19. return { browser : match[1] || "", version : match[2] || "0" };
  20. }
  21. var match = rOpera.exec(ua);
  22. if (match != null) {
  23. return { browser : match[1] || "", version : match[2] || "0" };
  24. }
  25. var match = rChrome.exec(ua);
  26. if (match != null) {
  27. return { browser : match[1] || "", version : match[2] || "0" };
  28. }
  29. var match = rSafari.exec(ua);
  30. if (match != null) {
  31. return { browser : match[2] || "", version : match[1] || "0" };
  32. }
  33. if (match != null) {
  34. return { browser : "", version : "0" };
  35. }
  36. }
  37. var browserMatch = uaMatch(userAgent.toLowerCase());
  38. if (browserMatch.browser) {
  39. browser = browserMatch.browser;
  40. version = browserMatch.version;
  41. }
  42. //document.write(browser);
  43. function OnCustomToolBarCommand(btnIdx){
  44. //ShowTipMessage("TIP:",""+btnIdx,true);
  45. alert("tip");
  46. alert(btnIdx);
  47. }
  48. function OnComplete2(type,code,html)
  49. {
  50. /*
  51. 谷歌浏览器事件接管
  52. */
  53. //alert(type);
  54. //alert(code);
  55. alert(html);
  56. alert("SaveToURL成功回调");
  57. }
  58. function OnComplete(type,code,html){
  59. //alert(type);
  60. //alert(code);
  61. alert(html);
  62. alert("BeginOpenFromURL成功回调");
  63. };
  64. function OnComplete3(str,doc)
  65. {
  66. TANGER_OCX_OBJ.activeDocument.saved=true;//saved属性用来判断文档是否被修改过,文档打开的时候设置成ture,当文档被修改,自动被设置为false,该属性由office提供.
  67. // TANGER_OCX_OBJ.SetReadOnly(true,"");
  68. //TANGER_OCX_OBJ.ActiveDocument.Protect(1,true,"123");
  69. //获取文档控件中打开的文档的文档类型
  70. switch (TANGER_OCX_OBJ.doctype)
  71. {
  72. case 1:
  73. fileType = "Word.Document";
  74. fileTypeSimple = "wrod";
  75. break;
  76. case 2:
  77. fileType = "Excel.Sheet";
  78. fileTypeSimple="excel";
  79. break;
  80. case 3:
  81. fileType = "PowerPoint.Show";
  82. fileTypeSimple = "ppt";
  83. break;
  84. case 4:
  85. fileType = "Visio.Drawing";
  86. break;
  87. case 5:
  88. fileType = "MSProject.Project";
  89. break;
  90. case 6:
  91. fileType = "WPS Doc";
  92. fileTypeSimple="wps";
  93. break;
  94. case 7:
  95. fileType = "Kingsoft Sheet";
  96. fileTypeSimple="et";
  97. break;
  98. default :
  99. fileType = "unkownfiletype";
  100. fileTypeSimple="unkownfiletype";
  101. }
  102. alert("ondocumentopened成功回调");
  103. }
  104. function publishashtml(type,code,html){
  105. alert(html);
  106. alert("Onpublishashtmltourl成功回调");
  107. }
  108. function publishaspdf(type,code,html){
  109. alert(html);
  110. alert("Onpublishaspdftourl成功回调");
  111. }
  112. function saveasotherurl(type,code,html){
  113. alert(html);
  114. alert("SaveAsOtherformattourl成功回调");
  115. }
  116. function dowebget(type,code,html){
  117. alert(html);
  118. alert("OnDoWebGet成功回调");
  119. }
  120. function webExecute(type,code,html){
  121. alert(html);
  122. alert("OnDoWebExecute成功回调");
  123. }
  124. function webExecute2(type,code,html){
  125. alert(html);
  126. alert("OnDoWebExecute2成功回调");
  127. }
  128. function FileCommand(TANGER_OCX_str,TANGER_OCX_obj){
  129. if (TANGER_OCX_str == 3)
  130. {
  131. alert("不能保存!");
  132. TANGER_OCX_OBJ.CancelLastCommand = true;
  133. }
  134. }
  135. function CustomMenuCmd(menuPos,submenuPos,subsubmenuPos,menuCaption,menuID){
  136. alert("第" + menuPos +","+ submenuPos +","+ subsubmenuPos +"个菜单项,menuID="+menuID+",菜单标题为\""+menuCaption+"\"的命令被执行.");
  137. }
  138. //var classidx64="A64E3073-2016-4baf-A89D-FFE1FAA10EE1";
  139. var classidx64="A64E3073-2016-4baf-A89D-FFE1FAA10EE1";
  140. var classid="A39F1330-3322-4a1d-9BF0-0BA2BB90E970";
  141. var codebase="OfficeControl.cab#version=5,0,3,0";
  142. var codebase64="ofctnewclsidx64.cab#version=5,0,2,9";
  143. if (browser=="IE"){
  144. //alert(window.navigator.platform);
  145. if(window.navigator.platform=="Win32"){
  146. document.write('<!-- 用来产生编辑状态的ActiveX控件的JS脚本--> ');
  147. document.write('<!-- 因为微软的ActiveX新机制,需要一个外部引入的js--> ');
  148. document.write('<object id="TANGER_OCX" classid="clsid:'+classid+'"');
  149. document.write('codebase="'+codebase+'" width="100%" height="700px"> ');
  150. document.write('<param name="IsUseUTF8URL" value="-1"> ');
  151. document.write('<param name="IsUseUTF8Data" value="-1"> ');
  152. document.write('<param name="BorderStyle" value="1"> ');
  153. document.write('<param name="BorderColor" value="14402205"> ');
  154. document.write('<param name="TitlebarColor" value="15658734"> ');
  155. document.write('<param name="TitleBar" value="0"> ');
  156. document.write('<param name="isoptforopenspeed" value="0"> ');
  157. document.write('<param name="ProductCaption" value="中国南方电网"> ');
  158. document.write('<param name="ProductKey" value="EC132527352A2F57546474CE7DEDD3B9ABDFE491">');
  159. document.write('<param name="TitlebarTextColor" value="0"> ');
  160. document.write('<param name="MenubarColor" value="14402205"> ');
  161. document.write('<param name="MenuButtonColor" VALUE="16180947"> ');
  162. document.write('<param name="MenuBarStyle" value="3"> ');
  163. document.write('<param name="MenuButtonStyle" value="7"> ');
  164. document.write('<param name="WebUserName" value="NTKO"> ');
  165. /*document.write('<param name="Caption" value="NTKO OFFICE文档控件示例演示 http://www.ntko.com"> ');*/
  166. document.write('<SPAN STYLE="color:red">不能装载文档控件。请在检查浏览器的选项中检查浏览器的安全设置。请点击<a href="NtkoCrossBrowserSetup20160522.msi">安装组件</a>;<a href="Register and uninstall_20150827.exe">清理组件</a></SPAN> ');
  167. document.write('</object>');
  168. }
  169. if(window.navigator.platform=="Win64"){
  170. document.write('<!-- 用来产生编辑状态的ActiveX控件的JS脚本--> ');
  171. document.write('<!-- 因为微软的ActiveX新机制,需要一个外部引入的js--> ');
  172. document.write('<object id="TANGER_OCX" classid="clsid:'+classidx64+'"');
  173. document.write('codebase="'+codebase64+'" width="100%" height="700px"> ');
  174. document.write('<param name="IsUseUTF8URL" value="-1"> ');
  175. document.write('<param name="IsUseUTF8Data" value="-1"> ');
  176. document.write('<param name="BorderStyle" value="1"> ');
  177. document.write('<param name="BorderColor" value="14402205"> ');
  178. document.write('<param name="TitlebarColor" value="15658734"> ');
  179. document.write('<param name="isoptforopenspeed" value="0"> ');
  180. document.write('<param name="TitlebarTextColor" value="0"> ');
  181. document.write('<param name="ProductCaption" value="中国南方电网"> ');
  182. document.write('<param name="ProductKey" value="EC132527352A2F57546474CE7DEDD3B9ABDFE491">');
  183. document.write('<param name="MenubarColor" value="14402205"> ');
  184. document.write('<param name="MenuButtonColor" VALUE="16180947"> ');
  185. document.write('<param name="MenuBarStyle" value="3"> ');
  186. document.write('<param name="MenuButtonStyle" value="7"> ');
  187. document.write('<param name="WebUserName" value="NTKO"> ');
  188. /*document.write('<param name="Caption" value="NTKO OFFICE文档控件示例演示 http://www.ntko.com"> ');*/
  189. document.write('<SPAN STYLE="color:red">不能装载文档控件。请在检查浏览器的选项中检查浏览器的安全设置。请点击<a href="NtkoCrossBrowserSetup20160522.msi">安装组件</a>;<a href="Register and uninstall_20150827.exe">清理组件</a></SPAN> ');
  190. document.write('</object>');
  191. }
  192. }
  193. else if (browser=="firefox"){
  194. document.write('<object id="TANGER_OCX" type="application/ntko-plug" codebase="'+codebase+'" width="100%" height="100%" ForOnSaveToURL="OnComplete2" ForOnBeginOpenFromURL="OnComplete" ForOndocumentopened="OnComplete3"');
  195. document.write('ForOnpublishAshtmltourl="publishashtml"');
  196. document.write('ForOnpublishAspdftourl="publishaspdf"');
  197. document.write('ForOnSaveAsOtherFormatToUrl="saveasotherurl"');
  198. document.write('ForOnDoWebGet="dowebget"');
  199. document.write('ForOnDoWebExecute="webExecute"');
  200. document.write('ForOnDoWebExecute2="webExecute2"');
  201. document.write('ForOnFileCommand="FileCommand"');
  202. document.write('ForOnCustomMenuCmd2="CustomMenuCmd"');
  203. document.write('_IsUseUTF8URL="-1" ');
  204. document.write('_ProductCaption="中国南方电网" ');
  205. document.write('_ProductKey="EC132527352A2F57546474CE7DEDD3B9ABDFE491"');
  206. document.write('_IsUseUTF8Data="-1" ');
  207. document.write('_BorderStyle="1" ');
  208. document.write('_BorderColor="14402205" ');
  209. document.write('_MenubarColor="14402205" ');
  210. document.write('_MenuButtonColor="16180947" ');
  211. document.write('_MenuBarStyle="3" ');
  212. document.write('_MenuButtonStyle="7" ');
  213. document.write('_WebUserName="NTKO" ');
  214. document.write('clsid="{'+classid+'}" >');
  215. document.write('<SPAN STYLE="color:red">尚未安装NTKO Web FireFox跨浏览器插件。请点击<a href="NtkoCrossBrowserSetup20160522.msi">安装组件</a>;<a href="Register and uninstall_20150827.exe">清理组件</a></SPAN> ');
  216. document.write('</object> ');
  217. }else if(browser=="chrome"){
  218. if(window.navigator.platform=="Win32"){
  219. document.write('<object id="TANGER_OCX" clsid="{'+classid+'}" ForOnSaveToURL="OnComplete2" ForOnBeginOpenFromURL="OnComplete" ForOndocumentopened="OnComplete3"');
  220. document.write('ForOnpublishAshtmltourl="publishashtml"');
  221. document.write('ForOnpublishAspdftourl="publishaspdf"');
  222. document.write('ForOnSaveAsOtherFormatToUrl="saveasotherurl"');
  223. document.write('ForOnDoWebGet="dowebget"');
  224. document.write('ForOnDoWebExecute="webExecute"');
  225. document.write('ForOnDoWebExecute2="webExecute2"');
  226. document.write('ForOnFileCommand="FileCommand"');
  227. document.write('_ProductCaption="中国南方电网" ');
  228. document.write('_ProductKey="EC132527352A2F57546474CE7DEDD3B9ABDFE491"');
  229. document.write('ForOnCustomMenuCmd2="CustomMenuCmd"');
  230. document.write('codebase="'+codebase+'" width="100%" height="700px" type="application/ntko-plug" ');
  231. document.write('_IsUseUTF8URL="-1" ');
  232. document.write('_IsUseUTF8Data="-1" ');
  233. document.write('_BorderStyle="1" ');
  234. document.write('_BorderColor="14402205" ');
  235. document.write('_MenubarColor="14402205" ');
  236. document.write('_MenuButtonColor="16180947" ');
  237. document.write('_MenuBarStyle="3" ');
  238. document.write('_MenuButtonStyle="7" ');
  239. document.write('_WebUserName="NTKO" ');
  240. /*document.write('_Caption="NTKO OFFICE文档控件示例演示 http://www.ntko.com"> ');*/
  241. document.write('<SPAN STYLE="color:red">尚未安装NTKO Web Chrome跨浏览器插件。请点击<a href="NTKO跨浏览器插件安装包.exe">安装组件</a>;<a href="Register and uninstall_20150827.exe">清理组件</a></SPAN> ');
  242. document.write('</object>');
  243. }
  244. if(window.navigator.platform=="Win64"){
  245. document.write('<!-- 用来产生编辑状态的ActiveX控件的JS脚本--> ');
  246. document.write('<!-- 因为微软的ActiveX新机制,需要一个外部引入的js--> ');
  247. document.write('<object id="TANGER_OCX" classid="clsid:'+classidx64+'"');
  248. document.write('codebase="'+codebase64+'" width="100%" height="100%"> ');
  249. document.write('<param name="IsUseUTF8URL" value="-1"> ');
  250. document.write('<param name="IsUseUTF8Data" value="-1"> ');
  251. document.write('<param name="BorderStyle" value="1"> ');
  252. document.write('<param name="BorderColor" value="14402205"> ');
  253. document.write('<param name="TitlebarColor" value="15658734"> ');
  254. document.write('<param name="isoptforopenspeed" value="0"> ');
  255. document.write('<param name="TitlebarTextColor" value="0"> ');
  256. document.write('<param name="ProductCaption" value="中国南方电网"> ');
  257. document.write('<param name="ProductKey" value="EC132527352A2F57546474CE7DEDD3B9ABDFE491">');
  258. document.write('<param name="MenubarColor" value="14402205"> ');
  259. document.write('<param name="MenuButtonColor" VALUE="16180947"> ');
  260. document.write('<param name="MenuBarStyle" value="3"> ');
  261. document.write('<param name="MenuButtonStyle" value="7"> ');
  262. document.write('<param name="WebUserName" value="NTKO"> ');
  263. /*document.write('<param name="Caption" value="NTKO OFFICE文档控件示例演示 http://www.ntko.com"> ');*/
  264. document.write('<SPAN STYLE="color:red">不能装载文档控件。请在检查浏览器的选项中检查浏览器的安全设置。请点击<a href="NTKO跨浏览器插件安装包.exe">安装组件</a>;<a href="Register and uninstall_20150827.exe">清理组件</a></SPAN> ');
  265. document.write('</object>');
  266. }
  267. }else if (Sys.opera){
  268. alert("sorry,ntko web印章暂时不支持opera!");
  269. }else if (Sys.safari){
  270. alert("sorry,ntko web印章暂时不支持safari!");
  271. }