In This Topic
Reference Guides / JavaScript API / Events / RegisterOnAttachmentClick

RegisterOnAttachmentClick

In This Topic
 RegisterOnAttachmentClick

This function allows you to trigger a function of your own before an attachment is opened.

RegisterOnAttachmentClick: function (docuViewareID, callback)

Example of usage

This JavaScript makes sure the DocuVieware control is properly loaded and initialized and then subscribes to the event on load.

function RegisterOnAttachmentClickOnAPIReady() {
    if (typeof DocuViewareAPI !== "undefined" && DocuViewareAPI.IsInitialized("DocuVieware1")) {
        DocuViewareAPI.RegisterOnAttachmentClick("DocuVieware1",
            function(param)  {
            //Uncomment line below to block navigation to {param.uri} URI
            //param.cancel = true;
            console.log(param);
        });
        }
    else {
        setTimeout(function () { RegisterOnAttachmentClickOnAPIReady() }, 10);
    }
}
document.addEventListener("DOMContentLoaded", function () {
    RegisterOnAttachmentClickOnAPIReady();
}, false);

Parameters

docuViewareID
The identifier for the DocuVieware™ instance.
callback
The function you want to execute on event.
The callback provides an argument having a prototype { uri, cancel }.
- fileName specifies the name of the attachment that will be subsequently opened.
- cancel is a boolean specifying whether the operation must be aborted (the receiver must set it to true for such purpose).

Return Value

0 if success. 1 if error.