Error msg: null or not an object?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Allan Bruun

    Error msg: null or not an object?

    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.a ll[...].style is null or not an object"

    This is what the files look like:

    Left.htm:
    <SCRIPT language=javasc ript 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.backgrou ndColor = "";}
    if (action == "out") { document.all[menunavn].style.backgrou ndColor = ""; }
    }

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

    What´s the problem here??

    Thanks!

    Allan Bruun
  • Evertjan.

    #2
    Re: Error msg: null or not an object???

    Allan Bruun wrote on 30 jun 2003 in comp.lang.javas cript:[color=blue]
    > document.all[menunavn].style.backgrou ndColor
    > "document.a ll[...].style is null or not an object"[/color]


    Needs a string:

    document.all["menunavn"].style.backgrou ndColor

    or:

    var menunavn="menun avn"
    document.all[menunavn].style.backgrou ndColor



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Error msg: null or not an object???

      post@abset.dk (Allan Bruun) writes:
      [color=blue]
      > 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.a ll[...].style is null or not an object"[/color]

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

      Which browser are you using?
      [color=blue]
      > This is what the files look like:
      >
      > Left.htm:
      > <SCRIPT language=javasc ript src="menuscript .js" type=text/javascript></SCRIPT>[/color]

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

      [color=blue]
      > menuscript.js:
      >
      > function lag(lagnavn, bil) // IE4+
      > {
      > if (document.all[lagnavn].style.display == 'none') {[/color]

      So, the error occurs in the call
      lag('headlag',d ocument.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 - lrn@hotpop.com
      Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      Working...