javascript - javascript中的行是什么意思?

标签 javascript internet-explorer firefox browser

  1. if (document.all)
  2. document.body.style.behavior='url(#default#homepage)';
  3. if (window.sidebar)

javascript 中的这些行是什么意思?谢谢。

最佳答案

Don’t use document.all:

if (document.all) {
   element = document.all[id];
else {
   element = document.getElementById(id);
}
  1. document.all 是在 Internet Explorer 4 中引入的,因为 W3C DOM 尚未标准化一种使用元素 ID 获取元素引用的方法。
    到 IE 5 出现时,document.getElementById() 已经标准化,因此,IE 5 包含了对它的支持。 More info here. .

  2. document.body.style.behavior='url(#default#homepage)'用于将当前页面设置为IE中的首页。

  3. if (window.sidebar) 是对 firefox 的检查

关于javascript - javascript中的行是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6757351/

相关文章:

javascript - 了解基于 CORS 的 XMLHttpRequest(responseText)

javascript - 谷歌可视化类别过滤器日期解析

javascript - 从数据库中提取数据并显示在排行榜中

javascript - IE AJAX 响应 trim 空 (0x00) 字符后的所有数据

html - 无法为输入文件提供顶部/左侧位置

按钮上的 jQuery 事件冒泡在 Firefox 中无法按预期工作

javascript - 如何在数组中使用具有顺序但不同名称的元素?

javascript - 禁用左键单击(用于心理实验),但在 IE 中焦点发生变化。如何预防?

html - 为什么 IE 不显示这个请求的背景图片?

css 动画在 chrome 和 safari 中工作而不在 mozilla 中工作