[英]From inside iframe want to get all iframe class name (each Iframe has a different class name)
我嘗試了以下代碼,
var iframes= parent.document.getElementsByTagName("iframe");
console.log(iframes[0].getAttribute("class"));
問題:上面的代碼正在基於索引[0]獲取iframe類,如果我想獲取第二個索引,我必須獲取iframes [1] .getAttribute(“ class”)。
可以動態獲取所有類並與xyz類fire函數進行比較
謝謝
嘗試這個
var iframes= parent.document.getElementsByTagName("iframe");
for(var i=0;i<iframes.length;i++){
if(iframes[i].getAttribute("class") == 'xyz'){
// do your stuff
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.