Cannot read property 'getElementsByTagName' of null
mkierdev opened this issue · 4 comments
mkierdev commented
When module is enabled, it throws error in console:
Cannot read property 'getElementsByTagName' of null
It occurs both on 2.3.2 and 2.4.0 version. What can we do about it?
loadkrnis commented
I think your code was executed before HTML elements was drawn.
solution is here.
window.onload = function () {
/* your code here */
}
mkierdev commented
@loadkrnis yeah, but how it applies to nuxt-gtm situation? I just followed everything from the docs - I put gtm into modules and than, I provided module with my GTM container. Nothing more. I don't even know where would I place your window.onload function
mkierdev commented
I found a solution - code inside gtm container caused this problem, not the gtm module itself, as I initially thought.
Thank you for quick response :)