Error msg: null or not an object???

A

Allan Bruun

Hi all!!

Could anyone help me with this annoying problem:

When I enter the site www.vans-nordic.com I get this error in the browser:

"document.all[...].style is null or not an object"

This is what the files look like:

Left.htm:
<SCRIPT language=javascript src="menuscript.js" type=text/javascript></SCRIPT>
.....
....
....

menuscript.js:

function lag(lagnavn, bil) // IE4+
{
if (document.all[lagnavn].style.display == 'none') {
document.all[lagnavn].style.display = 'block';
bil.src = 'pics/minus.png';
} else {
document.all[lagnavn].style.display = 'none';
bil.src = 'pics/plus.png';
}
}

function menu(action, menunavn)
{
if (action == "over") { document.all[menunavn].style.backgroundColor = "";}
if (action == "out") { document.all[menunavn].style.backgroundColor = ""; }
}

function skift(hvor, farve)
{
// husk # i kald til funktion
hvor.style.backgroundColor = farve;
}

What´s the problem here??

Thanks!

Allan Bruun
 
E

Evertjan.

Allan Bruun wrote on 30 jun 2003 in comp.lang.javascript:
document.all[menunavn].style.backgroundColor
"document.all[...].style is null or not an object"


Needs a string:

document.all["menunavn"].style.backgroundColor

or:

var menunavn="menunavn"
document.all[menunavn].style.backgroundColor
 
L

Lasse Reichstein Nielsen

Could anyone help me with this annoying problem:

When I enter the site www.vans-nordic.com I get this error in the browser:

"document.all[...].style is null or not an object"

My first check gave "document.all" has no properties. Then I noticed I had
accidentally used Mozilla instead of Opera. That's a hint: "document.all"
won't work *at all* in Mozilla based browsers.

Which browser are you using?
This is what the files look like:

Left.htm:
<SCRIPT language=javascript src="menuscript.js" type=text/javascript></SCRIPT>

Remember to put quotes around "text/javascript". The language
attribute is deprectaed and can be left out.

menuscript.js:

function lag(lagnavn, bil) // IE4+
{
if (document.all[lagnavn].style.display == 'none') {

So, the error occurs in the call
lag('headlag',document.images['headbil']);
I can't find an an element with id="headlag". That means that
document.all['headlag'] is undefined. The error message is a little
puzzling, as it sounds like it is document.all['headlag'].style that
is undefined, but I think that is just a bad error message. You are
using IE, right?

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top