示例git中的HTML文件:https://github.com/hiraghuak/iframe
我在iframe中的功能:
<script>
$(function () {
var iframes = parent.document.getElementsByTagName("iframe");
console.log(iframes + ' iframe');
for (var i = 0; i < iframes.length; i++) {
var iframeGetAttribute = iframes[i].getAttribute("class");
console.log(iframeGetAttribute + ' iframe GetAttribute');
if (iframeGetAttribute == 'xyz') {
// ITS ALL WORKING FINE
}
}
});
</script>
谢谢