if (document.all)
document.body.style.behavior='url(#default#homepage)';
if (window.sidebar)
什么是那些在javascript意思线?谢谢。javascript中的行含义是什么?
if (document.all)
document.body.style.behavior='url(#default#homepage)';
if (window.sidebar)
什么是那些在javascript意思线?谢谢。javascript中的行含义是什么?
不要使用的document.all:
if (document.all) {
element = document.all[id];
else {
element = document.getElementById(id);
}
的document.all是在Internet Explorer 4中引入的,因为W3C DOM还没有标准化抓住引用的方式到使用其ID的元素。
当IE 5出来时,document.getElementById()已经标准化,因此IE 5包含了对它的支持。 More info here.。
document.body.style.behavior='url(#default#homepage)'
用于将当前页面设置为IE中的主页。
if (window.sidebar)
是用于Firefoxdocument.all is used to check if the browser is IE
if (document.all)
:用来检查布劳尔是IE,但请注意,这是因为bad practice它不再做测试的一个好方法。
if (window.sidebar)
:测试浏览器是否为Firefox。
编辑:document.body.style.behavior='url(#default#homepage)';
最有可能使用to set the homepage when the browser is IE。但是,it does not seem to work well with Firefox and the others。
明白了,谢谢,waht的这句话的意思是? document.body.style.behavior = 'URL(#默认#主页)'; – zhuanzhou
1名试图检测该浏览器是IE和语句2使用的IE-仅API检查:behavior property。
但是,document.all不是IE专用功能。它也存在于Chromium/Chrome和其他基于WebKit的浏览器上。
因此,语句1通过IE & Chrome传递,但语句2仅适用于IE。
请忽略第一个:) – Ibu
嗨,你应该提供一个更大的摘录代码的答案是非常有用的。 – ocodo
我觉得这个编辑不正确 – Ibu