SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Oct 2001
    Location
    Montreal, Canada
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DOM support in browsers

    Hi all,

    Some questions:

    Opera support: is there a difference on DOM support between version 5 and 6? Because Opera 6 renders my page perfect wheras Opera5... I'm looking for a way to differentiate version 5 from version 6.

    IE support: Did getElementById() support started in version 5.0 or 5.5?

    Netscape support: Netscape 4 does not support getElementById(), right?

    Thanks for your time,

    Mike
    Dis donc, qu'est-ce qu'il dit ce mec? Hein? Je comprends rien...

  2. #2
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Netscape support: Netscape 4 does not support getElementById(), right?
    Correct.

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use something like

    PHP Code:
    if (document.all)//ie4
    {
      
    //code
    }
    else if (
    document.getElementById)
    {
      
    //code
    }
    else if(
    document.layers)// netscape
    {
      
    //code

    but the best way to reference objects is by doing something like this.

    document.parentNode or document.childNodes[0] //etc

    or simply passing the thing by this

    function call(what)
    {
    alert(what.value);
    }

    <a href="" onclick="call(this)">etc</a>

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, it's always best to avoid using browser specific code where possible! Passing the 'this' object around is much neater (although ever-so-slightly slower, but it makes no difference to 99.99% of scripts), not to mention the fact that it works with every browser that supports JavaScript, and is 100% guaranteed to be futureproof!
    Last edited by M@rco; Aug 12, 2002 at 12:39.
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oah all this time i never knew that, where did you find that one out?

  6. #6
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, now you ask, I can't seem to find any references to back that up, so for the moment ignore it.

    That does of course remove the only caveat, and therefore makes using 'this' a total no-brainer (no slowdown)!
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •