Hi all,
I'm having some fun with the good old "object expected" error from IE and was hoping you guys could help me out.
I get the error message Object Required : Line 86.
mmm cryptic as there is only 67 lines on that page but after some digging I managed to figureout that this line is the culprit:

subItemNAME = (MenuXML.getElementsByTagName(pageIs)[i].childNodes[0].nodeValue);

from this function:

function assembleSubMenu()
{

pageIs = (document.URL);
pageIs = (pageIs.split("/"));
pageIs = (pageIs[4].split("."));
pageIs = (pageIs[0]);

if ((pageIs == "contemporary") || (pageIs == "traditional") || (pageIs == "ultra-modern"))
	{
	preloadImgs(pageIs);
	}

subLength = (MenuXML.getElementsByTagName(pageIs).length);

if (subLength != 0)
	{
	document.getElementById("subMenuBOX").innerHTML = ("");
	for ( var i = 0; i <= (subLength - 1); i++ )
		{
		subItemNAME = (MenuXML.getElementsByTagName(pageIs)[i].childNodes[0].nodeValue);
		subItemNAME = (subItemNAME.split("$"));
		subItemTITLE = (subItemNAME[2]);
		subItemHREF = (subItemNAME[1]);
		subItemNAME = (subItemNAME[0]);
		subItemLEFT = (i * 25);
		tempPhrase = (document.getElementById("subMenuBOX").innerHTML);
		tempPhrase = (tempPhrase + phraseOne + i + phraseTwo + i + phraseThree + i + phraseFour + subItemHREF + phraseFive + subItemLEFT + phraseSix + subItemHREF + phraseSeven + subItemTITLE + phraseEight + subItemNAME + phraseNine);
		document.getElementById("subMenuBOX").innerHTML = (tempPhrase);
		}
	functionCallDROP();
	}
}

what all this does is create a sub-menu bar from the data in a XML file (in a very round about way i know)
works perfectly in FF, Chrome Safari and Opera but IE6 (that bloody thing!) throws all it's toys out of the pram when it gets to it.

any idea why?

MattTheHat,

I expect it's all goiing wrong at the pageIs=... stage.

There are more reliable ways to extract sections of a url.

If you post an original URL string and the part you need to extract from it (as pageIs ), then I'll see if I can build some better extractor code.

Airshow

What I want to do is get the bold bit out of from a URL like this:

http://www.ThisURL.com/Folder1/ThisPage.html

the XML document uses the page name to pull out the correct menu subsystem.

I appreciate your help on this.

Matt,

No worries.

Try this, as a single line replacement for your four pageIs= lines:

var pageIs = window.location.pathname.split('/').pop().split('.')[0];

Then try alerting pageIs to see if it's what you expect.

The line subItemNAME = MenuXML. .... looks like it should work cross-browser. I don't fully understand it because I haven't seen the XML it's working on. But this code looks OK.

However, if my pageIs line doesn't work, then you could try replacing subItemNAME = MenuXML. .... with:

subItemNAME = MenuXML.getElementsByTagName(pageIs)[i].innerHTML;

I've never tried using innerHTML on XML but have read that it should be OK.

No guarantees that any of this will work but maybe you'll get lucky.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.