読み込み時に Facebook のいいねボタンのカウント値を非表示にしようとしています。iframe
次のように、で実行されます。
<iframe src="//www.facebook.com/plugins/like.php?href='+'facebook.com'+'&send=false&layout=button_count&width=90&show_faces=false&action=like&colorscheme=light&font&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;margin:30px 0px 25px 0px;" allowTransparency="true"> </iframe>
そこで、次のような iframe タグに onload を挿入してみました。
onload="
function loadme() {
// pluginCountTextConnected is the like text count's classname
var x = document.getElementsByClassName('pluginCountTextConnected');
console.log(x);
}
loadme();
"
しかし、コードは空のリストを返します。document
この場合、参照はiframeドキュメントではなく、iframeをロードしたドキュメントを参照していると思います。これをiframeのコンテンツに向けるにはどうすればよいですか?
フィドル:ここ
iframe は、Facebook で実行されるコンテンツ スクリプトの Chrome 拡張機能から読み込まれることを付け加えておく必要があります。
更新: 誰かが閉鎖に投票したのはなぜですか?