当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


HTML DOM implementation用法及代码示例


HTML中的DOM实现属性用于返回与当前文档关联的DOMImplementation对象。 DOMImplementation是表示提供不依赖于任何特定文档的对象的方法的接口。

用法:

document.implementation

返回值:它返回文档实现对象。


范例1:

<!-- HTML code to check the document 
has HTML DOM 1.0 feature -->
<!DOCTYPE html> 
<html> 
    <head> 
        <title> 
            HTML DOM implementation Property 
        </title> 
          
        <script> 
            function DomFunction() { 
                var obj = document.implementation; 
                document.getElementById("demo").innerHTML  
                    = obj.hasFeature("HTML", "1.0"); 
            } 
        </script> 
    </head> 
      
    <body> 
        <h2>HTML DOM implementation Property</h2> 
          
        <p>Click on button to check the document 
        has HTML DOM 1.0 feature</p> 
          
        <button onclick = "DomFunction()"> 
            Click Here! 
        </button> 
          
        <p id = "demo"></p> 
    </body> 
</html>                    

输出:
之前单击按钮:

单击按钮后:

范例2:

<!DOCTYPE html> 
<html> 
    <head> 
        <title> 
            HTML DOM implementation Property 
        </title> 
    </head> 
      
    <body> 
        <h2>HTML DOM implementation Property</h2> 
        <script> 
            var DOM_Name = "HTML"; 
            var DOM_Ver = "1.0"; 
            var GFG = document.implementation.hasFeature(  
                        DOM_Name, DOM_Ver); 
              
            alert( "DOM " + DOM_Name + " " + DOM_Ver  
                + " supported? " + GFG ); 
        </script> 
    </body> 
</html>                                

输出:
dom

支持的浏览器:下面列出了DOM实现属性支持的浏览器:

  • 谷歌浏览器
  • IE浏览器
  • 火狐浏览器
  • Opera
  • 苹果浏览器


相关用法


注:本文由纯净天空筛选整理自AlieaRizvi大神的英文原创作品 HTML | DOM implementation Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。