JavaScript
  Home arrow JavaScript arrow Page 8 - JavaScript and Embedded Objects
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Download TestComplete 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
eWeek
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

JavaScript and Embedded Objects
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 43
    2004-10-26

    Table of Contents:
  • JavaScript and Embedded Objects
  • Java
  • Including Applets
  • Accessing Applets in JavaScript
  • Issues with JavaScript-Driven Applets
  • Plug-ins
  • MIME Types
  • Detecting Specific Plug-Ins
  • Interacting with Plug-Ins
  • Refreshing the Plug-Ins Array
  • Interacting with a Specific Plug-In
  • ActiveX
  • Cross-Browser Inclusion of Embedded Objects
  • Interacting with ActiveX Controls
  • Summary

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    JavaScript and Embedded Objects - Detecting Specific Plug-Ins
    (Page 8 of 15 )

    In Netscape 3+, Opera 4+, and Mozilla-based browsers, each plug-in installed in the browser has an entry in the plugins[] array of the Navigator object. Each entry in this array is a Plugin object containing information about the specific vendor and version of the component installed. Some interesting properties of the Plugin object are listed in Table 18-2.

    Each Plugin object is an array of the MimeType objects that it supports (hence its length property). You can visualize the plugins[] and mimeTypes[] arrays as being cross-connected. Each element in plugins[] is an array containing references to one or more elements in mimeTypes[]. Each element in mimeTypes[] is an object referred to by exactly one element in plugins[], the element referred to by the MimeType’s pluginEnabled reference.

    You can refer to the individual MimeType objects in a Plugin element by using double-array notation:

    navigator.plugins[0][2]

    This example references the third MimeType object supported by the first plug-in.

    More useful is to index the plug-ins by name. For example, to write all the MIME types supported by the Flash plug-in (if it exists!), you might write

    if (navigator.plugins["Shockwave Flash"])
    {
      for (var i=0; i<navigator.plugins["Shockwave
           Flash"].length; i++)
        document.write("Flash MimeType: " + navigator.plugins
          ["Shockwave Flash"][i].type + "<br />");
    }

    Of course, as with all things plug-in–related, you need to read vendor documentation very carefully in order to determine the exact name of the particular plug-in in which you are interested.

    Property Description
    description String describing the nature of the plug-in. Exercise caution with this property because this string can be rather long.
    name String indicating the name of the plug-in.
    length Number indicating the number of MIME types this plug-in is currently supporting.

    TABLE 18-2 Some Interesting Properties of the Plugin Object

    To illustrate the composition of the Plugin object more clearly, the following code prints out the contents of the entire plugins[] array:

    for (var i=0; i<navigator.plugins.length; i++)
    {
      document.write("Name: " + navigator.plugins[i].name + "<br />");
      document.write("Description: " + navigator.plugins[i].description + "<br />");
      document.write("Supports: ");
      for (var j=0; j<navigator.plugins[i].length; j++)
        document.write("   " + navigator.plugins[i][j].type);
        // the nonbreaking space included so the types are more readable
      document.write("<br /><br />");
    }

    The results are shown in Figure 18-5.

    Dealing with Internet Explorer

    One thing to be particularly conscious of is that Internet Explorer defines a faux plugins[] array as a property of Navigator. It does so in order to prevent poorly written Netscapespecific scripts from throwing errors while they probe for plug-ins. Under Internet Explorer, you have some reference to plug-in–related data through the document.embeds[] collection. However, probing for MIME types and other functions is not supported, since Explorer actually uses ActiveX controls to achieve the function of plug-ins included via an <embed> tag. For more information on using JavaScript with ActiveX, see the section entitled “ActiveX” later in this chapter. For now, simply consider that to rely solely on information from navigator.plugins[] without first doing some browser detection can have some odd or even disastrous consequences.


    FIGURE 18-5
    Example contents of the navigator.plugins[] array

    McGraw-Hill-OsborneThis chapter is from JavaScript: The Complete Reference, second edition, by Thomas Powell and Fritz Schneider, McGraw-Hill/Osborne, ISBN: 0072253576). Check it out at your favorite bookstore today.

    Buy this book now.

    More JavaScript Articles
    More By McGraw-Hill/Osborne


     

    JAVASCRIPT ARTICLES

    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...
    - Bulleted Menu of Links
    - Creating Click Loggers and Basic Markers wit...
    - Adding Pan Controls to Yahoo! Maps
    - Adding Zoom Controls to Yahoo! Maps
    - Working with Yahoo! Maps
    - Building Image Zooming Controls with the DOM...
    - Working with Multiple Graphics for a Zoom Ap...
    - Improving an Image Zooming Application with ...
    - Zooming in on Images with JavaScript
    - JavaScript Date Objects: Universal Coordinat...
    - Javascript Objects: More Date Methods
    - JavaScript Objects: Dates
    - JavaScript Objects: Finishing Strings

    Iron Speed

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway