I've gotten something working but I'd still like to see other answers. This puts the event handler outside of the JS file and into the document, but the code itself is still inside the JS file. The organization of the code was my greatest concern so this is acceptable to me.
var oTest = new Test();
function Test()
{
var oDevice = new ActiveXObject("This.That");
this.CancelOperation = function()
{
try
{
oDevice.CancelOperation();
return "CancelOperation successful.";
}
catch (e)
{
return e.message;
}
};
this.WireEvents = function()
{
var script = document.createElement("script");
script.type = "text/javascript";
script.text = 'function oTest.oDevice::DeviceStatusUpdate(wasSuccess, message, data) { document.getElementById("outBox").value += "Success: " + wasSuccess.toString() + "\\nMessage: " + message + "\\nData:" + data + "\\n\\n"; }';
document.body.appendChild(script);
};
}