Reputation: 2765
I'm using an institutional (ie, any fix will have to be on my side) website that is IE specific, but I want to use it with Safari. The website mostly works, but at one point I get the following error in my console:
Uncaught TypeError: Object #<HTMLFormElement> has no method 'all'
When I dig into the Javascript the error is coming from:
function fnFocus() {
var frmCtl = document.frmAddEditAdultPosition ;
if(frmCtl !=null) {
var ctlFN = frmCtl.all("txtFirstName") ;
ctlFN.focus() ;
}
}
Calls to the all method are scattered throughout the code.
My plan, is to use proxypy to fix the Javascript as it comes in. I'm assuming that the all method is something IE specific, but I don't know what I should replace it with.
Upvotes: 0
Views: 109
Reputation: 944215
The elements
collection:
frmCtl.elements["txtFirstName"] // Might be another collection if there are duplicate fields of that name
frmCtl.getElementsByName("txtFirstName") // Always a collection
or querySelector
:
frmCtl.querySelector('[name="txtFirstName"]') // Gets the first match
or querySelectorAll
:
frmCtl.querySelectorAll('[name="txtFirstName"]') // Always a collection
Upvotes: 1