2016-05-18 1 views
0

私は開いたカートの内線でラベルを印刷するためにqzprint APIを使用しています。すべてがうまくいきましたが、突然FFで作業を停止しました。インターネットエクスプローラでは正常に動作します。私がアプレットの機能でアラートを追加すると、それはFirefoxでもうまく動作しますが、警告が出ていない理由はわかりません。ここに私のコードです。Firefoxが正しく動作しません

uは私のdeployqzで見ることができるように(私のheader.tpl

<script type="text/javascript"> 
deployQZ('<?php echo HTTP_CATALOG ?>'); 
useDefaultPrinter(); 
<script> 

機能

function deployQZ(path) { 
//alert("alert for printing label"); 
    pathApplet = path + 'java/qz-print.jar'; 
    pathJnlp = path + 'java/qz-print_jnlp.jnlp'; 
    var attributes = {id: "qz", code:'qz.PrintApplet.class', 
     archive: pathApplet, width:1, height:1}; 
    var parameters = {jnlp_href: pathJnlp, 
     cache_option:'plugin', disable_logging:'false', 
     initial_focus:'false'}; 
    if (deployJava.versionCheck("1.7+") == true) {} 
    else if (deployJava.versionCheck("1.6+") == true) { 
     attributes['archive'] = 'java/jre6/qz-print.jar'; 
     parameters['jnlp_href'] = 'java/jre6/qz-print_jnlp.jnlp'; 
    } 
    deployJava.runApplet(attributes, parameters, '1.5'); 
} 

/** 
* Automatically gets called when applet has loaded. 
*/ 
function qzReady() { 
    // Setup our global qz object 
    window["qz"] = document.getElementById('qz'); 
    //var title = document.getElementById("title"); 
    if (qz) { 
     try { 
      //title.innerHTML = title.innerHTML + " " + qz.getVersion(); 
      //document.getElementById("content").style.background = "#F0F0F0"; 
     } catch(err) { // LiveConnect error, display a detailed meesage 
      document.getElementById("content").style.background = "#F5A9A9"; 
      alert("ERROR: \nThe applet did not load correctly. Communication to the " + 
       "applet has failed, likely caused by Java Security Settings. \n\n" + 
       "CAUSE: \nJava 7 update 25 and higher block LiveConnect calls " + 
       "once Oracle has marked that version as outdated, which " + 
       "is likely the cause. \n\nSOLUTION: \n 1. Update Java to the latest " + 
       "Java version \n   (or)\n 2. Lower the security " + 
       "settings from the Java Control Panel."); 
     } 
    } 
} 

    /** 
* Returns is the applet is not loaded properly 
*/ 
function isLoaded() { 
    if (!qz) { 
     alert('Error:\n\n\tPrint plugin is NOT loaded!'); 
     return false; 
    } else { 
     try { 
      if (!qz.isActive()) { 
       alert('Error:\n\n\tPrint plugin is loaded but NOT active!'); 
       return false; 
      } 
     } catch (err) { 
      alert('Error:\n\n\tPrint plugin is NOT loaded properly!'); 
      return false; 
     } 
    } 
    return true; 
} 

    function useDefaultPrinter() { 
    //alert("alert for printing label"); 
    if (isLoaded()) { 
     // Searches for default printer 
     qz.findPrinter(); 

     // Automatically gets called when "qz.findPrinter()" is finished. 
     window['qzDoneFinding'] = function() { 
      // Alert the printer name to user 
      var printer = qz.getPrinter(); 
      //alert(printer !== null ? 'Default printer found: "' + printer + '"': 
       //'Default printer ' + 'not found'); 
      document.getElementById("name_printer").innerHTML = 'Default printer found: "' + printer + '"'; 
      // Remove reference to this function 
      window['qzDoneFinding'] = null; 
      defaultFound = true; 
     }; 
    } 
} 

を含むアプレットファイルにアプレット関数を呼び出す)と私が持っているusedefaultprinter()関数ファイヤー・キツクでは機能しないとコメントされていて、それがうまく動作するとコメントされていない場合は、最初の行に警告します。コメントでは、isLoaded()関数から警告メッセージが表示されます。 "印刷プラグインが正しくロードされていません!"

はまた私のコンソールでは、私はアンバランスなツリーがネットワークからのデータを再解析することが原因のdocument.write()を使用して書かれたこの

を取得します。詳しくはhttps://developer.mozilla.org/en/Optimizing_Your_Pages_for_Speculative_Parsing

+0

タイミングの問題のように見えます。 if(isLoaded()){...} else {setTimeout(useDefaultPrinter、300); if(isLoaded()){...}に変更します。 } ' – mplungjan

+0

@mplungjanもし私がuseDefaultPrinter()を呼び出せなかったとしても、私にはエラーが出るので、deployqz()へと落ちると思います。 –

+0

最初の関数の前に' var qz; 'を追加してから' window ["qz "] =' to 'qz =' - 私は実際にはどこでも 'qzReady()'を見ないので、アプレットによって呼び出される可能性があります。コンソールにエラーがありますか? useDefaultPrinterという方法でqzReady()を延期して呼び出すことはできますか? – mplungjan

答えて

0

のためにこれを試してみてください:

  1. を準備、その関数内でuseDefaultPrinter入れるとqzReadyは、アプレットによって呼び出された場合。
  2. isLoadedは多少時間がかかる場合、あまりにもそこにuseDefaultPrinterを呼び出し、この

    <script type="text/javascript"> 
    deployQZ('<?php echo HTTP_CATALOG ?>'); 
    <script> 
    

    アプレットを含むファイル関数と同様のsetTimeout

を使用して

var qz; 

function deployQZ(path) { 
    pathApplet = path + 'java/qz-print.jar'; 
    pathJnlp = path + 'java/qz-print_jnlp.jnlp'; 
    var attributes = {id: "qz", code:'qz.PrintApplet.class', 
     archive: pathApplet, width:1, height:1}; 
    var parameters = {jnlp_href: pathJnlp, 
     cache_option:'plugin', disable_logging:'false', 
     initial_focus:'false'}; 
    if (deployJava.versionCheck("1.7+") == true) {} 
    else if (deployJava.versionCheck("1.6+") == true) { 
     attributes['archive'] = 'java/jre6/qz-print.jar'; 
     parameters['jnlp_href'] = 'java/jre6/qz-print_jnlp.jnlp'; 
    } 
    deployJava.runApplet(attributes, parameters, '1.5'); 
} 

/** 
* Automatically gets called when applet has loaded. 
*/ 
function qzReady() { 
    // Setup our global qz object 
    qz = document.getElementById('qz'); 
    if (qz) { 
     try { 
      useDefaultPrinter(); 
     } catch(err) { // LiveConnect error, display a detailed meesage 
      document.getElementById("content").style.background = "#F5A9A9"; 
      alert("ERROR: \nThe applet did not load correctly. Communication to the " + 
       "applet has failed, likely caused by Java Security Settings. \n\n" + 
       "CAUSE: \nJava 7 update 25 and higher block LiveConnect calls " + 
       "once Oracle has marked that version as outdated, which " + 
       "is likely the cause. \n\nSOLUTION: \n 1. Update Java to the latest " + 
       "Java version \n   (or)\n 2. Lower the security " + 
       "settings from the Java Control Panel."); 
     } 
    } 
    else { setTimeout(useDefaultPrinter,300); } 
} 

    /** 
* Returns is the applet is not loaded properly 
*/ 
function isLoaded() { 
    if (!qz) { 
     alert('Error:\n\n\tPrint plugin is NOT loaded!'); 
     return false; 
    } else { 
     try { 
      if (!qz.isActive()) { 
       alert('Error:\n\n\tPrint plugin is loaded but NOT active!'); 
       return false; 
      } 
     } catch (err) { 
      alert('Error:\n\n\tPrint plugin is NOT loaded properly!'); 
      return false; 
     } 
    } 
    return true; 
} 

function useDefaultPrinter() { 
    //alert("alert for printing label"); 
    if (isLoaded()) { 
     // Searches for default printer 
     qz.findPrinter(); 

     // Automatically gets called when "qz.findPrinter()" is finished. 
     window['qzDoneFinding'] = function() { 
      // Alert the printer name to user 
      var printer = qz.getPrinter(); 
      //alert(printer !== null ? 'Default printer found: "' + printer + '"': 
       //'Default printer ' + 'not found'); 
      document.getElementById("name_printer").innerHTML = 'Default printer found: "' + printer + '"'; 
      // Remove reference to this function 
      window['qzDoneFinding'] = null; 
      defaultFound = true; 
     }; 
    } 
    else { setTimeout(useDefaultPrinter,300); } 
} 
+0

これはうまくいきました..どうしたのですか?実際に間違っていますか?ありがとうalot! –

+0

更新を参照してください - 主な問題はuseDefaultPrinterを右ter展開。それは非同期だったので、qzReadyがとにかく走っていた – mplungjan

関連する問題