EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

compatMode property

Gets a value that indicates whether standards-compliant mode is switched on for the object.

Syntax

JavaScript

p = object.compatMode

 

Property values

Type: String

BackCompat

Standards-compliant mode is not switched on.

CSS1Compat

Standards-compliant mode is switched on.

Remarks

When standards-compliant mode is switched on (also called "strict mode"), Windows Internet Explorer displays the document according to the World Wide Web Consortium (W3C) Cascading Style Sheets (CSS) standard. When standards-compliant mode is not switched on (also called "quirks mode"), the document is displayed as it was displayed in previous versions of Internet Explorer.

The compatMode property is deprecated in Windows Internet Explorer 8 in favor of the documentMode property.

With Microsoft Internet Explorer 6 and later, you switch on standards-compliant mode by including the !DOCTYPE declaration at the top of your document, specifying a valid !DOCTYPE in the declaration, and in some cases, specifying the !DOCTYPE or !DOCTYPE. The !DOCTYPE element specifies the unique name of the Document Type Definition (DTD), and can be appended with the version number of the DTD. The !DOCTYPE element specifies the definition of the DTD that is specified in the !DOCTYPE. The !DOCTYPE element specifies the location of the DTD.

Examples

The !DOCTYPE declarations in the following examples specify conformance to the Transitional HTML 4.0 DTD. The declaration in the second example specifies the URL of the DTD. The declaration in the first example does not. The second declaration switches on standards-compliant mode with Internet Explorer 6 and later. The first declaration does not.

The compatMode property returns BackCompat with documents containing the declaration in the following example. This declaration does not switch on standards-compliant mode because it does not specify the URL of the Transitional HTML 4.0 DTD.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/compatModeCompat.htm


<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//en">

The compatMode property returns CSS1Compat with documents containing the declaration in the following example. This declaration switches on standards-compliant mode because it specifies the URL of the Transitional HTML 4.0 DTD.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/CompatModeCompliant.htm


<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//en" 
    "http://www.w3.org/TR/html4/loose.dtd">

See also

document
Reference
documentMode
Other Resources
CSS Enhancements in Internet Explorer 6

 

 

Afficher:
© 2014 Microsoft