admin管理员组文章数量:1328568
I have an markup with embed tag want to access #document contents.
Tried to traverse till embed tag after fetching couldn't able to access inner nodes however there is an function available getElementByTagName() or getElementByClassName() but it not helped
var embedContent = document.getElementById('embed1')
var parentContents = x.parentElement.parentNode.lastElementChild.getElementsByTagName('embed')
> [function, embed1: function]
Below able to access embed tag after this how to fetch values of respective tag
Is there alternate way to achieve this??If yes please provide any url or examples.
I have an markup with embed tag want to access #document contents.
Tried to traverse till embed tag after fetching couldn't able to access inner nodes however there is an function available getElementByTagName() or getElementByClassName() but it not helped
var embedContent = document.getElementById('embed1')
var parentContents = x.parentElement.parentNode.lastElementChild.getElementsByTagName('embed')
> [function, embed1: function]
Below able to access embed tag after this how to fetch values of respective tag
Is there alternate way to achieve this??If yes please provide any url or examples.
Share Improve this question asked Apr 25, 2017 at 12:21 rselvaganeshrselvaganesh 1,1222 gold badges18 silver badges31 bronze badges1 Answer
Reset to default 7The content of an <embed>
tag is essentially locked Shadow DOM - it's a whole new document that Chrome can access but you can't.
It's easy to check what properties you can access:
var xObj = document.getElementById('xObj');
for (var p in xObj) {
var value = null;
try {
value = xObj[p];
} catch (err) {}
if (value)
console.log(p, value);
}
<embed id="xObj" src="http://stackoverflow."> </embed>
Your best bet to actually get the HTML is to load that content yourself:
var response = await fetch(document.getElementById('embedTag').src);
本文标签: javascriptHow to access dom elements of document from embed tagStack Overflow
版权声明:本文标题:javascript - How to access dom elements of #document from embed tag? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742235293a2437967.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论