JS document.getElementById is not a function if you have a form with name = "document"

I had a strange problem with my site. Suddenly on the page I received a JS error document.getElementById is not a function. The problem was that I had a form with name="document".

It seems that if the form has an attribute name, then a variable is set in Javascript with the same name.

Where can I find the specifications for this?

+4
source share
2 answers

The behavior is defined in Section 6.3.3 Named Access to the Window Object of the HTML 5 Specification:

, , . Window . tree order, :

+4

, . .

@Andreas , : http://w3c.imtqy.com/html/browsers.html#named-access-on-the-window-object

6.3.3. Window: " Window . :... a, , area, embed, form, frameset, img object , ..." - Andreas

: https://html.spec.whatwg.org/multipage/dom.html#dom-document-forms

Document . - , , id , :

, , iframe, img , ;

id , ;

id img, , .

, , :

, .

.

, iframe , iframe- null, WindowProxy .

, , .

HTMLCollection, node, name.

, , :

, , , iframe, img , - , id, img, id, . , embed object , , , .

0

Source: https://habr.com/ru/post/1659034/


All Articles