This works:
parent.document.getElementById('iframeID').contentWindow.document.querySelectorAll('*[id^="elementId"]');
But this doesn't:
parent.document.getElementById('iframeID').querySelectorAll('*[id^="elementId"]');
According to querySelectorAll
's reference:
The Element method querySelectorAll() returns a static (not live) NodeList representing a list of elements matching the specified group of selectors which are descendants of the element on which the method was called.
If contentWindow
is a descendant of the iframe element, shouldn't the iframe element be recursively iterated until, eventually, contentWindow
and document
are encountered, as it is the case with, for example:
<div id="div1">
<div id="div2">
<div id="div3">
<div id="div4">
<div id="div5">
</div>
</div>
</div>
</div>
</div>
<script>
console.log(document.getElementById("div1").querySelectorAll('div'));
</script>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745087614a4610497.html
评论列表(0条)