Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Push Method workaround for lack of support in IE5

Status
Not open for further replies.

montego237

Technical User
Joined
Jul 4, 2006
Messages
1
Location
GB
Hi,

I understand that the javascript in IE5 doesn't support the PUSH() method of arrays, and have been researching and discovered that you need the add on:

if (typeof Array.prototype.push == "undefined") {
Array.prototype.push = function(str) {
this[this.length] = str;
}
}

however, does this need tweaking? My code which contains the PUSH method is:

function get_elements() {
var divs = document.getElementsByTagName("div");
var htags = document.getElementsByTagName(TAB_HEADINGS);
sections = [];
tabs = [];
headings = []
for(var i=0; i<divs.length; i++) {
if(divs.className == SECTION_CLASS) sections.push(divs);
}
for(var i=0; i<htags.length; i++) {
if(htags.className == TAB_CLASS) {
var span = document.createElement("span");
span.innerHTML = htags.innerHTML;
tabs.push(span);
headings.push(htags);
}
}
};

so I guess my question is how do I combine the add on with the existing code to make it work?

Any help would be greatly appreciated...

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top