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

BaseHref property (applet, object)

Browser support:
Returns the base URL for the object element.
Relative paths in the document are relative to the base URL. The base URL is the location of the current document by default, but it can be overridden by the base tag.
Use the baseURI property in Firefox, Opera, Google Chrome and Safari.


You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

String that represents the base URL.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the BaseHref property with Macromedia Flash Player.
It clearly focuses on cross-browser support only, and it isn’t standards-compliant, but there isn't any standards-compliant cross-browser way to embed a Flash application into a document with Flash Player detection.
    <base href="/external/examples/common/" />
    <script type="text/javascript">
        function GetBaseURL () {
            var obj = document.getElementById ("myObject");
            if ('BaseHref' in obj) {
                alert ("The base URL for the object:\n" + obj.BaseHref);
            else {
                if ('baseURI' in obj) {
                    alert ("The base URL for the object:\n" + obj.baseURI);
                else {
                    alert ("Your browser does not support this example!");
    <object id="myObject" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="300" height="120" 
        <param name="movie" value="swf/flash.swf" />
        <!-- Optional params -->
        <param name="play" value="true" />
        <param name="loop" value="true" />
        <param name="quality" value="high" />
        <!-- END Optional -->
        <embed src="swf/flash.swf" width="300" height="120" play="true" 
            loop="true" quality="high" 
            pluginspage="" /> 

    <br /><br />
    <button onclick="GetBaseURL ();">Get the base URL for the object</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content