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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object detection and Netscape 6

Status
Not open for further replies.

patter

Programmer
Sep 8, 2002
5
FR
Hi, having trouble with Object Detection script from (otherwise excellent) D. Goodman's JS Bible.

It works fine in IE4, NN4 (PC AND Mac), but NN6 (Mac) refuses to do anything once it gets to the initial IF:

Code:
if (document.getElementById())

The JS console says: 'Uncaught Exception:[Exception... "Too few parameters to method" code 1008' and other other things; locates the error, strangely, in the code for document.all, exactly here according to line number:

Code:
	if (document.all)
		{
		if(typeof obj == 'string')
		  {
		  return document.all(obj).style
//		  ERROR would be HERE ON THIS LINE (?)
		  }
		else
		  {
		  return obj.style
		  }
		}

I'm just about to give up Netscape6 compatibility (or change the design of the page, but I don't want to do that. If some wiz out there has an answer...

Haven't tested on NN6 PC.

Thanks, sorry for lengthy post.


Here's the full code:

Code:
function getObject(obj)

	{
	var theObj
	
	if (document.layers)
		
		{	

		if(typeof obj == 'string')
		  {
//		  just one layer deep
		  return document.layers[obj]
		  }
		else
		  {
//		  can be a nested layer
		  return obj
		  }
		}
	
	if (document.all)
		{
		if(typeof obj == 'string')
		  {
		  return document.all(obj).style
		  }
		else
		  {
		  return obj.style
		  }
		}  	  

	if (document.getElementById())

		{
		if(typeof obj == 'string')
		  {
		  return document.getElementById(obj).style
		  }
		else
		  {
		  return obj.style
		  }
		}
	return null
	}
 
Just remove () here:
[tt]
if (document.getElementById)
[/tt]
 
thanks Starway

actually the bug was in the text file I think.

Moving the code around in the function (changing the order of 'all', 'layers', 'GetElementById' within the function) I noticed the error followed along, always the same number of lines from the GetElementById 'if'.

So I just pasted some code into a new file, does work with ().

Thanks anyway, problem solved [bigcheeks]
 
Starway you were right (and I must be tired)

It WAS the ()

Apologies, thanx again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top