proxy - Extending an ActiveXObject in javascript -


I want to track some of the functionality in JavaScript for ActiveX object methods.

I usually make my active X objects like this: var tconn = new ActiveXObject ("Tconnector");

Every time I see the open method TCN and all other examples are activated on Ax control.

I can not modify the TCN prototype because there is no one in it!

I think I can create a dummy ActiveXObject function which creates a proxy object from proxy calls to the real. Can you help me do this?

NOTE: The straight cover cover is not out of the question, because 1000s are 1000s of calls within this active X already.

You can actually override ActiveXObject () .

This means that you can try to make transparent hooks on the proxy object and method call around the real object. This will mean that you have to create a proxy around every method and will be the property of your ActiveX object, unless you are absolutely sure that there is no code without calling a particular method or property.

I have created "MSXML2.XMLHTTP" Small Cover for the Object Probably you can run all kinds of problems, so take it with a grain of salt:

  var ActualActiveXObject = ActiveXObject; Var ActiveXObject = function (progid) {var ax = new ActualActiveXObject (progid); If (progid.toLowerCase () == "msxml2.xmlhttp") {var _ = _X: ax, _status: "duplicate", response text: "", responseXml: empty, ready space: 0, status: 0, status text: 0, OnReadyStateChange: null // Add other properties ...}; O._onReadyStateChange = function () {var self = o; Return work () {self.readyState = self._ax.readyState; Self.responseText = self._ax.responseText; Self.responseXml = self._ax.responseXml; Self.status = self._ax.status; Self.statusText = self._ax.statusText; If (self.onReadyStateChange) self.onReadyStateChange (); }} (); O.open = function (Bistrom method, BSTURL, Verseink, BistroT, BST password) {varAsync = (varAsync! == incorrect); This._ax.onReadyStateChange = this._onReadyStateChange this return._ax.open (bstrMethod, bstrUrl, varAsync, bstrUser, bstrPassword); }; O.send = function (varBody) {return..ax.send (varBody); }; // Add other methods ...} and {var o = ax; } Return O; } Function Test () {var r = New ActiveXObject ('Msxml2.XMLHTTP'); Warning (r._status); // "fake" r.onReadyStateChange = function () {alert (this.readyState); }; R. Open ("GET", "z.xml"); R.send (); Warning (r.responseText); }  

Disclaimer: Especially async / onReadyStateChange handling is probably not correct, and the code may also have other problems. As I said, it's just an idea to handle it carefully.

PS: A COM object is case-insensitive, when it comes to method- and property names. This wrapper (as in all javascript) is case-sensitive, for example, if your code calls both to "send ()" and "send ()" , Then you must put a skeleton "Send ()" method in the cover as well:

  o.Send = function () {return.send.apply (this, logic) ; };  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -