LodopsFuncs.js 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. var CreatedOKLodop7766=null;
  2. function getLodop(oOBJECT,oEMBED){
  3. var win = null;
  4. var showMessage ='';
  5. /**************************
  6. 本函数根据浏览器类型决定采用哪个页面元素作为Lodop对象:
  7. IE系列、IE内核系列的浏览器采用oOBJECT,
  8. 其它浏览器(Firefox系列、Chrome系列、Opera系列、Safari系列等)采用oEMBED,
  9. 如果页面没有相关对象元素,则新建一个或使用上次那个,避免重复生成。
  10. 64位浏览器指向64位的安装程序install_lodop64.exe。
  11. **************************/
  12. var strHtmInstall="<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='"+basePath+"resource/lodopActivex/install_lodop32.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
  13. var strHtmUpdate="<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='"+basePath+"resource/lodopActivex/install_lodop32.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
  14. var strHtm64_Install="<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='"+basePath+"resource/lodopActivex/install_lodop64.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
  15. var strHtm64_Update="<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='"+basePath+"resource/lodopActivex/install_lodop64.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
  16. var strHtmFireFox="<br><br><font color='#FF00FF'>(注意:如曾安装过Lodop旧版附件npActiveXPLugin,请在【工具】->【附加组件】->【扩展】中先卸它)</font>";
  17. var strHtmChrome="<br><br><font color='#FF00FF'>(如果此前正常,仅因浏览器升级或重安装而出问题,需重新执行以上安装)</font>";
  18. var LODOP;
  19. try{
  20. //=====判断浏览器类型:===============
  21. var isIE = (navigator.userAgent.indexOf('MSIE')>=0) || (navigator.userAgent.indexOf('Trident')>=0);
  22. var is64IE = isIE && (navigator.userAgent.indexOf('x64')>=0);
  23. //=====如果页面有Lodop就直接使用,没有则新建:==========
  24. if (oOBJECT!=undefined || oEMBED!=undefined) {
  25. if (isIE)
  26. LODOP=oOBJECT;
  27. else
  28. LODOP=oEMBED;
  29. } else {
  30. if (CreatedOKLodop7766==null){
  31. LODOP=document.createElement("object");
  32. LODOP.setAttribute("width",0);
  33. LODOP.setAttribute("height",0);
  34. LODOP.setAttribute("style","position:absolute;left:0px;top:-100px;width:0px;height:0px;");
  35. if (isIE) LODOP.setAttribute("classid","clsid:2105C259-1E0C-4534-8141-A753534CB4CA");
  36. else LODOP.setAttribute("type","application/x-print-lodop");
  37. document.documentElement.appendChild(LODOP);
  38. CreatedOKLodop7766=LODOP;
  39. } else
  40. LODOP=CreatedOKLodop7766;
  41. };
  42. //=====判断Lodop插件是否安装过,没有安装或版本过低就提示下载安装:==========
  43. if ((LODOP==null)||(typeof(LODOP.VERSION)=="undefined")) {
  44. if (navigator.userAgent.indexOf('Chrome')>=0)
  45. showMessage = strHtmChrome + showMessage;
  46. if (navigator.userAgent.indexOf('Firefox')>=0)
  47. showMessage = strHtmFireFox + showMessage;
  48. if (is64IE) showMessage = strHtm64_Install; else
  49. if (isIE) showMessage = strHtmInstall; else
  50. showMessage = strHtmInstall + showMessage;
  51. } else if (LODOP.VERSION<"6.1.9.8") {
  52. if (is64IE) showMessage = strHtm64_Update + showMessage; else
  53. if (isIE) showMessage = strHtmUpdate + showMessage; else
  54. showMessage = strHtmUpdate + showMessage;
  55. };
  56. //=====如下空白位置适合调用统一功能(如注册码、语言选择等):====
  57. LODOP.SET_LICENSES("深圳市优软科技有限公司","BBF53BD5AB0D522B3207D05CDE381F65","","");
  58. //============================================================
  59. if(showMessage){
  60. if(!win){
  61. win = new Ext.window.Window({
  62. id: 'win-loadActiveX',
  63. modal: true,
  64. layout: 'anchor',
  65. html:showMessage,
  66. buttonAlign: 'center',
  67. buttons: [{
  68. text: $I18N.common.button.erpCloseButton,
  69. cls: 'x-btn-blue',
  70. handler: function(btn) {
  71. btn.ownerCt.ownerCt.hide();
  72. }
  73. }]
  74. });
  75. }
  76. win.show();
  77. }
  78. return LODOP;
  79. } catch(err) {
  80. if (is64IE)
  81. showMessage="Error:"+strHtm64_Install+showMessage;else
  82. showMessage="Error:"+strHtmInstall+showMessage;
  83. return LODOP;
  84. };
  85. }