There is an application I use at work that only functions in old versions of Internet Explorer. I've come to find that the reason for this is due to a script in an ASPX file which accesses the document.forms property incorrectly following logon:
document.forms('frmAutoSubmit').DocList.value = window.WebCtl1.GetDocDirectoryList('');
I created a Google Chrome Extension to address the issue, since I don't have the application's source code, nor do I have access to change the application in any way. The extension creates a script element and attaches it to the page. Here is the code that executes:
**inject.js**
(function (document) {
var i = 0, j = document.forms.length;
// Extend document to allow functional use
document._forms = [];
for (; i < j; ++i) {
document._forms[i] = document.forms[i];
}
document.forms = function (form) {
return document._forms[form];
};
console.debug('done');
})(document);
After loading the extension and testing the page, I still get the same error, even though my console.debug
statement executes first.
done inject.js:18
Uncaught TypeError: Property 'forms' of object #<HTMLDocument> is not a function
Is document.forms
a readonly and unalterable parameter? Is there another way to attack this?