Why Google Tag Manager puts both display:none AND visibility:hidden on iframe?

北战南征 提交于 2020-01-25 01:03:30

问题


If you take a look at the <noscript> part of the Google Tag Manager embed code, you'll notice something like:

<noscript><iframe style="display:none;visibility:hidden" src="//www.googletagmanager.com/..." height="0" width="0"></iframe></noscript>

I can understand why style="display:none" would be important (it will hide the element such that it takes up zero space in the layout and yet still fetches the content) however, why add the "visibility:hidden" part? It seems to me like it adds no additional value, so I'm assuming there must be some edge case or legacy or mobile browser that doesn't behave correctly without it.

Anyone know about this?


回答1:


Could be a thing to make sure screenreaders don't ever tell anyone about it. Looks like some people have found this to be problematic otherwise over here: http://juicystudio.com/article/screen-readers-display-none.php#comment3

I haven't tested this, so I can't confirm any of it, but layout-wise it should not make any differences as display:none instructs to remove the element from the layout all together, so making it invisible doesn't change anything.



来源:https://stackoverflow.com/questions/30608165/why-google-tag-manager-puts-both-displaynone-and-visibilityhidden-on-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!