SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member echozone's Avatar
    Join Date
    Aug 2003
    Location
    Eugene, Oregon
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    changing object detection

    Is it ok to change:

    if (document.images)

    to:

    if (document.getElementById)

    in a simple script JUST for the purpose of disabling the script for Netscape 4?

    The script actually works in Netscape 4, and that's why it originally uses
    if (document.images)
    but there's one part in my implementation that breaks in Netscape 4, and disabling it is fine, as it just displays an image instead of a slide show.

    I realize this might not be the ultimate purpose of this code, but it works for this.
    I got this from the tutorial here:
    http://javascriptkit.com/javatutors/objdetect3.shtml

    I just wanted to check if there's any repercussions unknown to me from simply changing - if (document.images) to - if (document.getElementById).

    I realize this will also disable it in IE 4, and that is fine.

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    If you want to remove Netscape 4 support only, use this instead:
    Code:
    if (!document.layers)
    But, if you are still using document.images in your script AND using document.getElementById, then use this:
    Code:
    if (document.images && document.getElementById)

  3. #3
    SitePoint Member echozone's Avatar
    Join Date
    Aug 2003
    Location
    Eugene, Oregon
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for responding. If I want to support the original document.images, and only disable in Netscape 4, is this proper syntax? It works in the browsers I test, and disables it in N4.

    Code:
    if (document.images && !document.layers)

  4. #4
    SitePoint Guru
    Join Date
    Mar 2004
    Location
    Earth
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, but make sure it's in the <body> section - document.layers is not a reliable test from the <head> section


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
  •