{"id":37488841,"url":"https://github.com/zspitz/activex-js-helpers","last_synced_at":"2026-01-16T07:34:52.272Z","repository":{"id":57172891,"uuid":"80349538","full_name":"zspitz/activex-js-helpers","owner":"zspitz","description":"Event handler management, and parameterized property setters for ActiveX objects in Javascript","archived":false,"fork":false,"pushed_at":"2020-09-03T08:58:08.000Z","size":146,"stargazers_count":5,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-23T03:39:11.538Z","etag":null,"topics":["activex","events","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zspitz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-29T14:07:24.000Z","updated_at":"2024-03-07T20:46:33.000Z","dependencies_parsed_at":"2022-08-24T13:21:31.542Z","dependency_job_id":null,"html_url":"https://github.com/zspitz/activex-js-helpers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zspitz/activex-js-helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspitz%2Factivex-js-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspitz%2Factivex-js-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspitz%2Factivex-js-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspitz%2Factivex-js-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zspitz","download_url":"https://codeload.github.com/zspitz/activex-js-helpers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspitz%2Factivex-js-helpers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activex","events","javascript"],"created_at":"2026-01-16T07:34:51.766Z","updated_at":"2026-01-16T07:34:52.259Z","avatar_url":"https://github.com/zspitz.png","language":"JavaScript","readme":"Also available via [npm](https://www.npmjs.com/package/activex-helpers).\n\n# Event handler management\n\nThere are a [number of mechanisms for handling ActiveX events](https://msdn.microsoft.com/en-us/library/ms974564.aspx) in Javascript; however, they all require that:\n* the variable must be initialized before the function declaration is evaluated. This is harder than it seems, because of [function declaration hoisting](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function#Function_declaration_hoisting); and requires doing one of the following:\n   * wrap the function declaration within an IIFE (this works because function declarations are only hoisted to the function scope),\n   * some form of string-to-code evaluation -- `eval`, `setTimeout`, `window.execScript`, `new Function`, or\n   * wrap the function within a `SCRIPT` block, while the initialization happens before the `SCRIPT` block (either in another `SCRIPT` block, or by setting the `id` of a previous element); this also implies that the `id`/variable must be available to the global scope.\n* the function must have a special name -- depending on the environment and event handling mechanism, either `variable.eventName`, `variable::eventName`, or `variable_eventName`\n* the function must be a [function declaration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions#Defining_functions), not a function expression\n* the parameters of the function must exactly match those defined in the ActiveX event\n\n```\nvar wdApp = new ActiveXObject('Word.Application');\n\n//using eval\neval('function wdApp::Quit() {window.alert(\\'Application quit\\');}');\n\n//using an IIFE\n(function() {\n  function wdApp::Quit() {\n    window.alert('Application quit');\n  }\n})();\n```\n\nThis library enables the following:\n```\n(function() {\n  var wdApp = new ActiveXObject('Word.Application');\n  \n  //using a function expression, without a special name\n  ActiveXObject.on(wdApp, 'Quit', function() {\n    window.alert('Application quit');\n    \n    //`this` binding\n    window.alert(this.Version);\n  });\n\n  //when the event is defined as passing parameters, the parameters are wrapped into a single object\n  //the object is passed into the final event handler\n  //AFAIK there is no way to determine the parameters at runtime, so the names must be passed in at registration\n  ActiveXObject.on(wdApp, 'DocumentBeforeSave', ['Doc','SaveAsUI','Cancel'], function (params) {\n    //changes to the `params` object are propagated back to the internal handler\n    params.SaveAsUI = false;\n    params.Cancel = !window.confirm(\"Do you really want to save?\");   \n  });\n})();\n```\n# Property setter\n\nProperty getters and setters without parameters are represented as Javascript simple read/write properties. However, while getters with paraneters are represented as methods, setters with parameters are represented as assignment to methods.\n```\nvar dict = new ActiveXObject('Scripting.Dictionary');\n\n//setter with parameters\ndict.Item('a') = 1;\n```\nThis is non-standard Javascript. The library enables calling setters with parameters in a standard Javascript-compliant fashion:\n```\nActiveXObject.set(dict, 'Item', ['a'], 1);\n```\n# Usage\n\nThis library relies on a number of ES5 array methods. The necessary shims are available in `shims.js`, in the absence of another shim library.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzspitz%2Factivex-js-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzspitz%2Factivex-js-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzspitz%2Factivex-js-helpers/lists"}