7 out of 13 rated this helpful - Rate this topic

BASE element | base object

[This documentation is preliminary and is subject to change.]

Specifies an explicit URL used to resolve links and references to external sources such as images and style sheets.

HTML 4.01 Specification, Section 12.4

Standards information

DOM Information

Inheritance Hierarchy

 Node
  Element
   HTMLElement
     base

Remarks

When used, the base element must appear within the head of the document, before any elements that refer to an external source.

If more than one base element occurs, only the first element will be recognized.

Windows Internet Explorer 8 and later. When read, the value of the href attribute depends on the current document compatibility mode. In addition, relative URL's are no longer supported by the base element.

Note   Versions of Windows Internet Explorer prior to Windows Internet Explorer 7 would allow the base element to appear anywhere in the document tree, which caused relative paths to use the "nearest" base element as the base for the URL. Internet Explorer 7 strictly enforces the use of the base tag within the head of the document, and will ignore misplaced tags.

Examples

This example sets the base URL of the document to a reference folder. Internet Explorer uses the base element to resolve the link to http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/href_2.asp.


<html>
<head>
  <base href="http://msdn.microsoft.com/workshop/author/dhtml/reference/"/>
</head>
<body>
Click <a href="properties/href_2.asp">here</a> to learn about the 
href property.
</body>
</html>

This example retrieves the base URL from the document if a valid base element is specified in the document. Otherwise, the function returns null.


<script>
function GetBase()
{
    var oBaseColl = document.all.tags('BASE');
    return ( (oBaseColl && oBaseColl.length) ? oBaseColl[0].href : 
        null );
}
</script>

 

 

Build date: 3/8/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
clarification
That "... Internet Explorer 7 strictly enforces the use of the base tag within the head of the document...," was not all that certain ... but is solid-certain for MSIE-8, now.