LodopsFuncs.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. width: '100%',
  64. height: '100%',
  65. modal: true,
  66. layout: 'anchor',
  67. html:showMessage,
  68. buttonAlign: 'center',
  69. buttons: [{
  70. text: $I18N.common.button.erpCloseButton,
  71. cls: 'x-btn-blue',
  72. handler: function(btn) {
  73. btn.ownerCt.ownerCt.hide();
  74. }
  75. }]
  76. });
  77. }
  78. win.show();
  79. }
  80. return LODOP;
  81. } catch(err) {
  82. if (is64IE)
  83. showMessage="Error:"+strHtm64_Install+showMessage;else
  84. showMessage="Error:"+strHtmInstall+showMessage;
  85. return LODOP;
  86. };
  87. }