You are here: Reference > JavaScript > client-side > HTML DOM > properties > type (a, applet, embed, link, object)

type property (a, applet, embed, link, object)

Browser support:
Specifies or returns the content type (MIME type) of the object or the linked object.
To avoid any inconsistencies, specify the exact MIME type for the linked object. If you want to specify the MIME type of an application that can be used for the data of an object element, use the codeType property.

Syntax:

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

Possible values:

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

Example HTML code 1:

This example illustrates the use of the type attribute for a elements:
<a id="myAnchor" href="testVideo.mpg" type="video/mpeg">Click to see the movie</a>
Did you find this example helpful? yes no

Example HTML code 2:

This example shows how to link a style document into a HTML document:
Code
style.css
<head>
    <link rel="stylesheet" type="text/css" href="style.css" />
</head>
Did you find this example helpful? yes no

Example HTML code 3:

This example illustrates the use of the type attribute for object elements:
Code
HelloWorld.java
<object type="application/x-java-applet" code="HelloWorld.class" width="200px" height="50px">
    <param name="codebase" value="/external/examples/common/java/" />
</object>
Did you find this example helpful? yes no

Example HTML code 4:

This example shows how to tell the client's browser that you offer a search plugin from HTML. If the search provider is currently installed it will be selected search engine. Note that the AddSearchProvider method provides similar functionality in JavaScript.
Code
searchProvider.xml
<head>
    <link rel="search" type="application/opensearchdescription+xml" 
        href="searchProvider.xml" title="Dottoro Search" /> 
</head>
<body>
    Please open the drop-down menu of your browser's Search Box.
</body>
Did you find this example helpful? yes no

Example HTML code 5:

This example illustrates the use of the type property:
<head>
    <script type="text/javascript">
        function GetAnchorType () {
            var anchor = document.getElementById ("myAnchor");
            alert ("The anchor type = " + anchor.type);
        }
    </script>
</head>
<body>
    <a id="myAnchor" href="testVideo.mpg" type="video/mpeg">Click to Movie</a>
    <button onclick="GetAnchorType ();">Get anchor type!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content