By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,380 Members | 1,621 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,380 IT Pros & Developers. It's quick & easy.

Error msg: null or not an object?

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2

P: n/a
po**@abset.dk (Allan Bruun) writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.