Wordpress插件加载问题中的打印操作

时间:2019-05-04 22:40:41

标签: javascript html wordpress

我正在尝试将WebPRNT打印按钮嵌入到woocommerce pos扩展中,并且不允许进行打印。非常感谢您的协助。

尝试通过下面的代码加载,但没有通过Java插入,但未声明变量StarWebPrintBuilder。我已经从我的阅读方式中得到了声明。

<script type='text/javascript'>
<!--
var builder = new StarWebPrintBuilder();

var request = '';

var sampleCode = 'var url = "http://localhost:8001/StarWebPRNT/SendMessage";
var papertype ="";

var builder = new StarWebPrintBuilder();
request += builder.createAlignmentElement({position:'center'});
request += builder.createCutPaperElement({feed:true, type:'full'});
request += builder.createPeripheralElement({channel:1, on:200, off:200});

var trader = new StarWebPrintTrader({url:url, papertype:papertype});
trader.onReceive = function (response) { alert(response.responseText); }
trader.onError = function (response) { alert(response.responseText); }
trader.sendMessage({request:request});';

function updateSampleCode() {
    var url              = document.getElementById('url').value;
    var papertype        = document.getElementById('papertype').value;

    document.getElementById('message').value =
        'var url = "' + url + '";\n' +
        'var papertype ="' + papertype + '";\n\n' +
        'var builder = new StarWebPrintBuilder();\n' + sampleCode + '\n' +
        'var trader = new StarWebPrintTrader({url:url, papertype:papertype});\n' +
        'trader.onReceive = function (response) { alert(response.responseText); }\n' +
        'trader.onError = function (response) { alert(response.responseText); }\n' +
        'trader.sendMessage({request:request});\n';
}
function onSendMessage() {
    updateSampleCode();

    showNowPrinting();
    var url              = document.getElementById('url').value;
    var papertype        = document.getElementById('papertype').value;

    var trader = new StarWebPrintTrader({url:url, papertype:papertype});

    trader.onReceive = function (response) {
    }

<input id="sendBtn" type="button" value="Send" onclick="onSendMessage()">

现在它停留在通过GUI加载页面上,并在控制台中返回“ Uncaught ReferenceError:未定义StarWebPrintBuilder”。我需要能够加载页面并打印由onSendMessage编译的信息,该信息由SampleCode变量编译。

0 个答案:

没有答案