HTML

1个成员

HTML元素 - base

发表于 2017-02-05 3657 次查看
定义
指定一个显式 URL 用于解析对于外部源的链接和引用,如图像和样式表。
Specifies an explicit URL used to resolve links and references to external sources such as images and style sheets.
元素说明
当使用时,base 元素必须出现在文档的 head 内,在任何用于引用外部资源的元素之前。
此元素在 Internet Explorer 3.0 及以上版本的 HTML 中可用,在 Internet Explorer 4.0 及以上版本的脚本中可用。
此元素不改变内容的显示格式。
此元素不需要关闭标签。
When used, the base element must appear within the head of the document, before any elements that refer to an external source.
This element is available in HTML as of Internet Explorer 3.0, and in script as of Internet Explorer 4.0.
This element is not rendered.
This element does not require a closing tag.
示例代码
下面的例子设置了文档的基础 URL 到一个引用文件夹。Internet Explorer 使用 base 元素来解析指向 http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/href_2.html 的链接。
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>


下面的例子表示,如在文档中指定了合法的 base 元素,则从文档中获取基础 URL;反之,返回 null。
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>
发表回复
你还没有登录,请先登录注册