たぼさんの部屋

いちょぼとのんびり

implement.createHTMLDocument("")で生成したcontainerでgetElementByIdが出来ないワケ

異なるcontainer(document)ではユニークなidを捜査する方法がないため、実装されていないようですね。

If you use getElementById to with document like - document.getElementById then it always works.

But however, if we perform the same on an element say x like x.getElementById, then it returns an error.

The unusual thing about this is that getElementsByClassName and getElementsByTagName work on the elements however getElementById doesn't!

Container IDs should be unique, so there's no reason to find an object by ID within another container. This is why you only need document.getElementById to access any element by its ID, whereas when you are searching by class or tag name, you might want to only search within a specific container, which is why you can do x.getElementsByClassName etc.