简体   繁体   中英

Print each emit in Node.js

I'm trying to print my Messages in a Node.JS/Socket.JS Web-App. In Firefox I've made the option, that he doesn't popup the normally Print-Dialog.

Now my Code is:

$(document).ready(function(){
    // WebSocket
    var socket = io.connect();

    //register Printer
    socket.emit('join', {name:"print-direct"});
    // neue Nachricht
    var a = 0;
    socket.on('msg', function (data) {
        var zeit = new Date(data.zeit);
        var innerHTML = $('#content_text').html();

        $('#content_text').html(innerHTML+'<div class="msg" id="'+a+'">Name "+data.name+'</font><br><font size="+2">'+data.msg+'</font></div>');
        $('#'+a).printElement();
        $("#"+a).remove();
        a++;
    });
});

Do you Have an idea how i can fix this?

Thanks!

PS: This is the Print-Plugin I've used http://projects.erikzaadi.com/jQueryPlugins/jQuery.printElement/

Sorry my rep is too low to comment, but is this code in your front-end? If so, you can simply use console.log in your javascript and it will show up in your developer console in Firefox.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM