PDA

View Full Version : IE 7 - object does not support this property or method



Silver65
02-29-2012, 05:58 PM
Now I've seen a few threads about this error and how in most cases it was a simple issue of declaring a variable with "var". However, if you take a look at the code below I don't think that is exactly the issue.

The var that IE is having trouble with I believe is mediaSelect, but as you can see I declared it outside of the function as another function also accesses this array.


var mediaSelect = new Array();

function DoCheckAll(chkAll)
{
var tbl = document.getElementById('tblMediaTypes');
var chk = tbl.getElementsByTagName('input');

for (var i=1; i<chk.length; i++)
{
chk[i].checked = chkAll.checked;
if (!chk[i].checked)
{
var index = mediaSelect.indexOf(chk[i].name);
if(index != -1)
mediaSelect.splice(index, 1);
}
else
{
var index = mediaSelect.indexOf(chk[i].name);
if(index == -1)
mediaSelect.push(chk[i].name);
}
}
}

So does anyone have any ideas / suggestions? If you need more details please let me know.

I have checked out this page on a MAC using Chrome 17.0.963, Firefox 3.5.16, and Safari 5.0.4. - All which work fine
I just tried checking this out on a PC using IE 7 and it doesn't work while returning the error. It did work on Firefox 2.0. The PC I'm forced to use is a POS so checking with any other browser would require 3 hours to install it.

Silver65
02-29-2012, 06:15 PM
Ok after a bit more investigation (Google searches) I believe I narrowed it down to the use of .indexOf() as it is only supported past IE 9.

I changed "var index = mediaSelect.indexOf(chk[i].name);" to "var index = $.inArray(chk[i].name, mediaSelect);" Seems to work out. Gracious to...me. Hope this may help others though.