QuirksMode& JavaScript实现 [英] QuirksMode & JavaScript Implementation

查看:81
本文介绍了QuirksMode& JavaScript实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下QuirksMode中的Internet Explorer是否具有与IE正常模式(正确定义了文档类型)下不同的JavaScript实现.

I would like to ask if Internet Explorer in QuirksMode has a different JavaScript implementation than IE in a normal mode (when doctype is correctly defined).

JavaScript代码是否有可能在QuirksMode和普通IE模式下以不同的方式表现?

Is it possible that a JavaScript code will behave in a different way in QuirksMode and in normal IE mode?

推荐答案

.

最明显的区别之一是在怪癖模式下,BODY(document.body)被认为是 root元素,而在标准模式下(及其含义)是-root元素是HTML(document.documentElement).

One of the most noticeable differences is that in quirks mode, BODY (document.body) is considered to be root element, whereas in standard mode (and the way it's meant to be) - root element is HTML (document.documentElement).

例如,这会影响通常计算视口尺寸的方式;在标准模式下,人们会使用document.documentElement.clientHeight,而在怪癖中使用document.body.clientHeight-来获取视口的高度.

This, for example, affects the way viewport dimensions are usually calculated; in standard mode, one would use document.documentElement.clientHeight, while in quirks - document.body.clientHeight - to get height of a viewport.

检测这种行为很容易-document.documentElement.clientHeight == 0-会告诉我们documentElement不是不是根元素,而应该使用主体.

Detecting this behavior is easy - document.documentElement.clientHeight == 0 - would tell us that documentElement is not the root element, and that body should be used instead.

当然还有其他常见的怪癖模式差异,例如分配无单位的CSS值,会导致不同的结果.在进行古怪的操作时,通常会成功分配此类值,而在标准模式下,这些值将被忽略.

And of course other usual quirks mode discrepancies, such as assigning unitless CSS values, result in a different outcome. When in quirks, such values are traditionally assigned successfully, whereas in standards mode - they are ignored.

这篇关于QuirksMode& JavaScript实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆