Accessing elements from player.getIframe() object?

隐身守侯 提交于 2020-08-06 06:42:07

问题


As per https://developers.google.com/youtube/iframe_api_reference

player.getIframe():Object

This method returns the DOM node for the embedded <iframe>.

How can I access the elements of the DOM node like I can do with the parent page's DOM, such as document.getElementById("example")?


回答1:


Here are the children under that player.getIframe():Object

<iframe id="player" frameborder="0" allowfullscreen="1" title="YouTube video player" width="640" height="390" src="https://www.youtube.com/embed/R98hoTffg0E?enablejsapi=1&amp;origin=http%3A%2F%2Flocalhost%3A8080&amp;widgetid=1"></iframe>

in short, they are:

id, frameborder, allowfullscreen, title, width, height, src

To access them, you'd do something like:

player.getIframe().id
player.getIframe().title

player is the youtube player instance taken from the same docs you provided.



来源:https://stackoverflow.com/questions/46124910/accessing-elements-from-player-getiframe-object

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