Error msg: null or not an object???

Discussion in 'Javascript' started by Allan Bruun, Jun 30, 2003.

  1. Allan Bruun

    Allan Bruun Guest

    Hi all!!

    Could anyone help me with this annoying problem:

    When I enter the site I get this error in the browser:

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

    This is what the files look like:

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


    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 = farve;

    What´s the problem here??


    Allan Bruun
    Allan Bruun, Jun 30, 2003
    1. Advertisements

  2. Allan Bruun

    Evertjan. Guest

    Allan Bruun wrote on 30 jun 2003 in comp.lang.javascript:

    Needs a string:



    var menunavn="menunavn"
    Evertjan., Jun 30, 2003
    1. Advertisements

  3. 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?
    Remember to put quotes around "text/javascript". The language
    attribute is deprectaed and can be left out.

    So, the error occurs in the call
    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?

    Lasse Reichstein Nielsen, Jun 30, 2003
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.