Hopefully I can ask this in an understandable way...
Overall, I am trying to determine what type of object I am currently dealing with.
I'm creating a collection (HTML is example, not literal) and I need to filter my collection to certain elements eg:
<div id=tabContentWrap>
<div id=tab>
<a href=http://somelink>Link Element</a><img src=img.jpg alt=img />
<select id=my_select><option value=1>1</option></select>
</div>
</div>
function getFilteredElements() {
var tabContent = getElementsByClass(tabContentWrap, document.getElementById(tabWrapId), div);
for (var j = 0; j < tabContent.length; j++){
tabContentLinks = tabContent[j].getElementsByTagName('*');
for (var k = 0; k < tabContentLinks.length; k++){
// Here i attempt to filter the collection
if (tabContentLinks[k] == '[object HTMLSelectElement]') {
alert(found select list);
}
}
}
}
Which works fine in Mozilla but not in Internet Explorer 8, tabContentLinks[k]
returns [object]
instead of [object 'ObjectType']
So I investigated and discovered that you can use Object.prototype.toString.call(object)
to get the object type, which again works fine in Mozilla but returns [object Object]
in IE8...
I call
get_type(tabContentsLink[k]);
which runs the following function:
function get_type(thing){
if (thing === null) return [object Null];
// special case
return Object.prototype.toString.call(thing);
}
But this just returns [object Object]
Does Object.prototype.toString.call()
ever return the type of object in IE or am I very far off and barking up a lamppost instead of a tree?