DocuVieware Reference Guide
RegisterOnDocumentClosed
Reference Guides > JavaScript API > Events > RegisterOnDocumentClosed
 RegisterOnDocumentClosed

This function allows you trigger a function of your own when the document closed event is fired.

RegisterOnDocumentClosed: function (docuViewareID, callback)

Parameters

docuViewareID
The identifier for the DocuVieware™ instance.
callback
The function you want to execute on document closed event.

Return Value

1 if error.

Example of usage

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

function RegisterOnDocumentClosedOnDocuViewareAPIReady() {
    if (typeof DocuViewareAPI !== "undefined" && DocuViewareAPI.IsInitialized("DocuVieware1")) {
        DocuViewareAPI.RegisterOnDocumentClosed("DocuVieware1", function () { console.log("document closed"); });
    }
    else {
        setTimeout(function () { RegisterOnDocumentClosedOnDocuViewareAPIReady() }, 10);
    }
}
document.addEventListener("DOMContentLoaded", function () {
    RegisterOnDocumentClosedOnDocuViewareAPIReady();
}, false);