Using a variable for document.getElementById

Discussion in 'Javascript' started by X l e c t r i c, Apr 2, 2007.

  1. webtv versions prior to 2.9 do not recognize document.getElementById, so
    we have to use a conditional that includes document.all.

    I've been trying to use a variable for document.all and
    document.getElementById to simplify my functions. It works for the
    latest versions of Explorer, Opera, and webtv. It does not work for the
    latest versions of Firefox, Netscape, and SeaMonkey.

    Here are two examples of what I'm trying to do. It's the "DOM "with" a
    variable" versions that don't work with all the browsers.

    Using divisions:

    http://www.xlectric.com/info/js/domvartest.html

    Using forms:

    http://www.xlectric.com/info/js/domvartestfm.html

    I realize that with the forms versions I can use the forms array, like I
    do in the third example. It works and it's valid. It's with the
    divisions versions that something like this would really simplify my
    functions. I even tried making a separate function that I could use as a
    method within the oC() function, but I was never able to sort that out
    either.

    Also, the results were the same when using the HTML 4.01 strict dtd.

    If it is possible to make something like this work for all the browsers,
    then I would appreciate it if it could be pointed out what I'm doing
    wrong.

    Art
    X l e c t r i c, Apr 2, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wk
    Replies:
    5
    Views:
    162
    Dietmar Meier
    Apr 22, 2005
  2. Replies:
    6
    Views:
    237
  3. Martin
    Replies:
    3
    Views:
    136
  4. weston
    Replies:
    19
    Views:
    215
  5. Replies:
    4
    Views:
    154
    Jonas Raoni
    Nov 21, 2006
Loading...

Share This Page