JavaScript Tutorial/Document/Plugin

Материал из Web эксперт
Перейти к: навигация, поиск

IE Plugin

<html>
<head>
<script language="Javascript" type = "text/javascript">
<!--
if ((navigator.userAgent.indexOf("MSIE") != -1) &&
 (navigator.userAgent.indexOf("Win") != -1)){
  document.writeln("<script language="VBscript">");
  document.writeln("Function IEPluginDetect(pluginname)");
  document.writeln("  on error resume next");
  document.writeln("     IEPluginDetect = False");
  document.writeln("     IEPluginDetect = IsObject(CreateObject(pluginname))");
  document.writeln("     If (err) then");
  document.writeln("        IEPluginDetect = False");
  document.writeln("     End If");
  document.writeln("End Function");
  document.writeln("</script>");
}
//-->
</script>
</head>
<body>
<script>
<!--
    document.write("<b>Macromedia Flash Plugin: </b>"  + IEPluginDetect("ShockwaveFlash.ShockwaveFlash"));
// -->
</script>
</body>
</html>


Plugin

The Plugin object is used to obtain plug-in information from the browser.

The Plugin object contains an array of elements containing the MIME types handled by each plug-in.

Property Description description Refers to a description of the plug-in filename Refers to the filename of a plug-in program length Refers to the number of MIME types supported name Refers to the plug-in name



<html>
    <head>
    <title> Example of the Plugin object</title>
    </head>
    <body>
    <script language="JavaScript">
    <!--
    for(i=0; i<navigator.plugins.length; i++){
         document.write(navigator.plugins[i].description);
    }
    -->
    </script>
    </body>
    </html>


Plugin.description

The description property obtains a description of the browser plug-ins.



<html>
    <head>
    <title> Example of the plugin description property</title>
    </head>
    <body>
    <script language="JavaScript">
    <!--
         document.write(navigator.plugins[0].description);
    -->
    </script>
    </body>
    </html>


Plugin.filename

The filename property gets the path and filename for a plug-in.



<html>
    <head>
    <title> Example of the plugin filename property</title>
    </head>
    <body>
    <script language="JavaScript">
    <!--
         document.write(navigator.plugins[0].filename);
    -->
    </script>
    </body>
    </html>


Plugin.length

The length property determines the number of MIME data types the plug-in can support.



<html>
    <head>
    <title> Example of the plugin length property</title>
    </head>
    <body>
    <script language="JavaScript">
    <!--
        document.write(navigator.plugins.length);
    -->
    </script>
    </body>
    </html>


Plugin.name

The name property gets the plug-in"s name.



<html>
    <head>
    <title> Example of the plugin name property</title>
    </head>
    <body>
    <script language="JavaScript">
    <!--
         document.write(navigator.plugins[0].name);
    -->
    </script>
    </body>
    </html>