Q
差異[0]
4
A
回答
5
document.all
給你到含有在Internet Explorer(IE)文檔的所有元素的數組狀對象的引用。 Document.forms[0]
給你一個指向文檔中的第一個表單元素的指針,在所有瀏覽器中
這兩個是非常不同的。如果您的表單有名稱屬性,請說'myform',那麼在IE中表單可以用document.all.myform
來引用document.all
已從IE版本5及以上版本棄用。你仍然可以使用它,即使在IE9中它仍然可用。通常它被用來測試,如果瀏覽器是IE:
if (document.all) {
//o no, it's IE again! We have to do it another way!
}
在document.forms[0]
形式引用的形式被認爲是不好的做法。更多,可以發現here
注:由於這個答案是第一次寫IE11已經介紹了下降的更多信息的document.all See Compatibility changes in IE11支持
3
該物業的document.all是所有的數組文檔中的HTML元素。而Document.forms [0]是文檔中的第一個表單。你應該避免使用document.all。
Internet Explorer 4中引入了 的document.all DOM(文檔對象模型 ),以允許各 部分網頁的訪問。在此之後不久, 標準DOM方法getElementById 被引入,因此 可用於所有版本5+瀏覽器。 這意味着的document.all 引用只需要 支持IE4.Just大約無人運行IE4 任何更多的 的document.all DOM支持這樣不再需要 。
要了解有關如何使用document.form [0]的更多信息,請參閱this。
0
首先,您使用document.all.myform來訪問您的表單。 第二格式,你可以使用document.forms [0]訪問您的形式
both one two is same in function but two is better than one
document.all.myform using this your searching all the way rome.
相關問題
- 1. 差異= 0
- 2. 它是0和-0之間的差異
- 3. Python解決差異爲0
- 4. = 0,='0',IN(0),IN('0')之間的SQL差異
- 5. AskToUpdateLinks = False和UpdateLinks之間的差異:= 0
- 6. 的Cron表達差異*/5和0/5
- 7. C++:0和0.0之間的差異?
- 8. 功能找到差異返回0
- 9. 差[0]
- 10. 是什麼sys.exit(0)和os._exit之間的差異(0)
- 11. JUnit測試:從不(0)和次(0)之間的差異
- 12. mov eax,0和mov ax之間的機器碼差異,0
- 13. PHP - DateTime差異()顯示兩個日期與一年差異的0個月?
- 14. 差[0] ++ ++和常用3 [0]
- 15. 差(DD,DATEDIFF(DD,0,DateColumn()),0)
- 16. 差異 - 文件差異
- 17. 差異
- 18. 差異
- 19. 差異
- 20. 差異
- 21. 差異
- 22. 差異
- 23. 差異
- 24. 差異
- 25. 差異
- 26. 差異
- 27. 差異
- 28. 差異
- 29. 差異
- 30. 差異
@Kooilnc所以這兩種方法纔有用在IE瀏覽器?假設我們想要在Chrome或Safari中運行相同的代碼做什麼? – Mihir 2011-04-08 05:43:55
@Mhhir:bottom line =你可以在Internet Explorer中使用'document.all',你只會在Internet Explorer <5中明確需要它。所以'document.forms'可用於所有瀏覽器,包括IE。 – KooiInc 2011-04-08 05:48:01
@Kooilnc oh..cool謝謝 – Mihir 2011-04-08 05:48:59