HTML5 actual combat and analysis of HTMLDocument changes
I have previously introduced you to some of the new additions to HTML5, and I believe you all have some understanding of them. Today I will introduce to you the newly added content about HTMLDocument in HTML5. So what are the newly added contents about HTMLDocument in HTML5? The newly added contents about HTMLDocument in HTML5 include readyState attribute, compatibility mode judgment and head attribute. Let me introduce these newly added little things to you one by one.
1. readyState attribute
As early as the IE4 era, the document object introduced the readyState attribute, but it has never been included in the standard. Now, in HTML5 As time goes by, it has been incorporated into the norm. The readyState attribute has two possible values:
(1) loading, the document is being loaded
(2)complete, the document has been loaded
How to use document appropriately What about .readyState? The most appropriate way to use document.readyState is to use it to implement an indicator that the document has been loaded. Until this property is widely supported, implementing such an indicator will still require the onload event handler to set a label indicating that the document has been loaded. The following example is as follows
HTML code
<p>梦龙小站</p> <p class="complete"></p>
JavaScript code
<script type="text/javascript"> window.onload = function(){ var a = 0; var b = 0; if(document.readyState == "complete"){ $(".complete").html( "加载好了" ) } if(document.readyState == "loading"){ $(".load").html( $(".load").html() + "<br/>" + a++ ) } };
Preview effect
2. Compatibility mode judgment
After IE6, it began to distinguish the modes of rendering pages, divided into standard and mixed, and detect the compatibility mode of the page. It becomes a necessary function of the browser. IE adds an attribute called compatMode to the document for this purpose. This attribute is to tell the developer which rendering mode the browser uses. As shown in the small example below, in standard mode, the value of document.compatMode is equal to "CSS1Compat", while in promiscuous mode, the value of document.compatMode is equal to "BackCompat".
JavaScript code
if(document.compatMode == "CSS1Compat"){ alert("标准模式") }else{ alert("混杂兼容模式") }
3. Head attribute
As a supplement to the body element of the document referenced by document.body, HTML5 adds a new document.head attribute, so that the head tag can be referenced. The usage method is as follows
JavaScript code
var head = document.head || document.getElementsByTagName("head")[0];
Make the compatibility as above. If it can be used, use document.head, otherwise still use the getElementsByTagName() method. The browsers supported by the document.head attribute are Chrome and Safari 5.
HTML5 actual combat and analysis of HTMLDocument changes (readyState attribute, compatibility mode and head attribute) are introduced here. Learn some new knowledge in the midst of your busy schedule. Life is still very fulfilling, and put your learning into practice. I would like to share some little things with you, it was such a magical day. Updates related to HTML5 practice and analysis.
【Related recommendations】
1. Free h5 online video tutorial
3. php.cn original html5 video tutorial
4. HTML5 game framework cnGameJS development record-detailed resource loading module code

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
