HTML DOM id 属性

定义和用法

id 属性可设置或返回 <base> 元素的 id。

语法

  1. baseObject.id=id

实例

下面的例子可返回 <base> 元素的 id:

  1. <html>
  2. <head>
  3. <base id="myBaseId" href="http://www.yousite.com/htmldom/" />
  4. </head>
  5.  
  6. <body>
  7. <p>Base id:
  8. <script type="text/javascript">
  9. x=document.getElementsByTagName('base')[0];
  10. document.write(x.id);
  11. </script>
  12. </body>
  13.  
  14. </html>

输出:

  1. Base id: myBaseId