Results 1 to 2 of 2

Thread: document.images

  1. #1
    Join Date
    Dec 1969

    Default document.images

    Hi,<BR><BR>Here&#039s a simple question. When there is the following code:<BR>if (document.images) {<BR>code<BR>}<BR><BR>In which case will the code be executed?

  2. #2
    Join Date
    Dec 1969

    Default RE: document.images

    You code will be executed when the user&#039s browser has to ability to understand the "documuent.images" reference. What&#039s happening here is that the if condition is checking for a true condition. In this case, if the user&#039s browser has the ability to see the images collection in the "document" object, then the value it true.<BR><BR>A better example is:<BR>if(document.all){ code }<BR>if(document.layers){ code }<BR><BR>In this scenerio, the first condition checks to see if the browsers acknowledges the "ALL" collection in the document object. If the browser can see this collection then the condition evaluates to true. Likewise the second condition checks for the "layers" collection in the document object.<BR><BR>Only IE 4.+ can see the "ALL" Collection in the document object and only Netscape 4.+ can see the "layers" collection. There for, this is a good way to do browser sniffing if you are looking for 4.+ browsers which subscribe to either IE or Netscape interpretation of the Document Object Model.

Posting Permissions

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