mixed onBeforeNewMessage ( messageObject )

It activates before rendering a new chat message, offering the ability to modify it.

As opposed to the onNewMessage event, instead of an array of messages, only one message is sent as a parameter. In other words, for each message, "onBeforeNewMessage" is triggered individually, enabling you to prohibit its rendering by returning "false".

In order for the message to be handled without changes, the "onBeforeNewMessage" event handler has to return the object obtained in the "messageObject" argument without modification.

The object message contains the following properties:

PropertyTypeDescription
a integer Message author code. Possible values:
260 Operator message
270, 271 Visitor message
450, 451 Automatic operator message
m string Message text.
n String Message author name
s binary true -- absolutely new message. false -- repeat rendering of old message
t string Message registration time in "hh:mm" by Moscow standard time.

Examples

  1. With jQuery
    $(document).on("netroxbeforenewmessage", function(event, message) {
        // Your actions
        return message;
    });       
  2. Using the nsc_API object
    nsc_API = { /* ... */ };
    
    nsc_API.onBeforeNewMessage = function(message) {
        // Your actions
        return message;
    };        

All rights reserved. Copyright © 2017 Netrox SC
Host CMS