JavaScript and Browser Plugins
Plugin Generalities
What is a plugin ?
What are MIME types ? (also Content-Type)
Plugins are registered for handling specific MIME types
(e.g. application/x-shockwave-flash application/pdf application/x-java-applet) navigator.mimeTypes and enabledPlugin
There are lots of browser plugins for almost any kind of application: Adobe Flash, Java Applets, QuickTime, Windows Media Player, Adobe Acrobat, Silverlight about:plugins and Manage Add-ons
Plugin Usage
General usage through <object> tag
Deprecated usage through <embed>, <applet>
Combining object and embed: <object ..><embed ..></embed></object>
InternetExplorer and ActiveXObject: type vs. classid Object tag attributes: type, data, codebase, classid,
codetype, archive
Object inner parameters: <param name= value= /> Embed attributes: type, src, pluginspace
Applet attributes: code, codebase, archive
Common HTML attributes and specific attributes
Plugin Scriptability
MAYSCRIPT attribute: accessing JavaScript from plugin
Plugins can call and use JavaScript functions and objects: netscape.javascript.JSObject.getWindow() fscommand(command, args)
JavaScript can access public plugin members or even instantiate plugin types and classes:
var javaVersion = Packages.java.lang.System.getProperty(java.version);
JavaScript can control FlashPlayer with methods: IsPlaying, Play, StopPlay, Rewind
Flash8+ exports methods with
ExternalInterface.addCallback()
and calls JavaScript with ExternalInterface.call()
Homework
Create an HTML page that uses a plugin (Flash / Applet) and interact with it from JavaScript by calling methods / properties