You are here: Reference > JavaScript > client-side > HTML DOM > properties > codeType (applet, object)

codeType property (applet, object)

Browser support:
Sets or retrieves the MIME type (media type) of the application that should be used by the object element.
If you don't specify this property, browsers try to determine the application that can be used for the data of the object element. Generally, you don't need to specify this property, leaving the choice to the browser.
Use the type property, if you want to specify the MIME type of the contents.

Syntax:

object.codeType;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: codeType

Possible values:

String that sets or retrieves the media type. See the page for the MIME types for more information.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the codeType attribute. The classid property specifies the HelloWorld.class file to play and the codeBase parameter sets the path to the HelloWorld.class file. Internet Explorer, Google Chrome and Safari do not support the classid property in this form.
Code
HelloWorld.java
<object codetype="application/x-java-applet" classid="java:HelloWorld" width="300px" height="100px">
    <param name="codebase" value="/external/examples/common/java/" />
        Your browser does not support Java applications in this form.
</object>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the codeType attribute in the case when a .wmv file needs to played with Windows Media Player:
<object codetype="application/x-mplayer2" data="testVideo.wmv" width="320px" height="286px">
    <param name="FileName" value="testVideo.wmv" />
        Your browser does not know how to execute Windows Media Player.
</object>
Did you find this example helpful? yes no

Example HTML code 3:

This example illustrates the use of the codeType property:
Code
HelloWorld.java
<head>
    <script type="text/javascript">
        function GetCodeType () {
            var object = document.getElementById ("myObject");
            alert (object.codeType);
        }
    </script>
</head>
<body onload="CreateObject ();">
    <object id="myObject" codetype="application/x-java-applet" classid="java:HelloWorld" width="300px" height="100px">
        <param name="codebase" value="/external/examples/common/java/" />
            Your browser does not support Java applications in this form.
    </object>
    <button onclick="GetCodeType ();">Get codeType</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content