Bitrix Site Manager

oBXEditorUtils.addDOMHandler

void
oBXEditorUtils.addDOMHandler(
   function handler[,
   int orderInd]
);

The oBXEditorUtils.addDOMHandler method adds a specified handler function to which the document content will be passed to be processed, as the DOM structure.

A handler function added using this method can address nodes of an edited document at the load time (in the visual mode), and when switching from the HTML mode to WYSIWYG.

The DOM handler receives a document after it has been processed by handlers installed using the addContentParser and addPHPParser methods.

Parameters

Parameter Description
handler A globally declared function.

A handler receives a reference to the document object of an edited document. Returns nothing.

Example


function myDOMHandler(oDocument)
{
    //do some actions
    var arIMG = oDocument.getElementsByTagName('IMG');
    var iLen = arIMG.length;
    for (var i=0;i < iLen;i++)
        arIMG[i].src = 'my_new_image.jpg';
}

//Add the handler
oBXEditorUtils.addDOMHandler(myDOMHandler);
This handler replaces the src attribute of all document pictures with my_new_image.jpg (leaving other attributes unchanged).