如何运行在加载时操作 iframe 内容的代码
how to run code that manipulates an iframe's content when it loads?
我试图在加载时隐藏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="
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扩展加载的,这就是为什么我认为这可能不受同源政策的约束。
更新:为什么有人投票关闭?
iframe未托管在您的域上,因此您无法访问它,请查看 http://en.wikipedia.org/wiki/Same_origin_policy
相关文章:
- 如何操作iframe之外的元素
- 使用jQuery来foreach iframe-src,并通过函数获取ID和操作
- 如何使用jquery操作iframe对象
- 如何运行在加载时操作 iframe 内容的代码
- 动态更改表单操作以生成iframe
- Iframe详细说明操作
- 如何在用户到达iframe分区末尾时显示操作按钮
- html表单操作跨域目标iframe
- 每次 iframe 重新导航时执行操作.(JavaScript)
- 将内容脚本注入到不同扩展名的操作弹出窗口中的 iframe 中
- 从 iframe 进行跨域拖放操作
- 在 iframe 中提交表单时的双重操作
- 发布到iframe,但iframe将顶部窗口重定向到操作url,而不是self
- 当iframe内容出现window.close时,请执行某些操作
- 在iframe的src内部的视图中操作html元素
- Chrome扩展-插入的Iframe无法访问Chrome浏览器操作或Chrome.tables或AngularJS
- 从打开的窗口在iFrame中对DOM进行Javascript操作
- 在可编辑iframe中使用execCommand()时,如何执行与退格相同的操作
- 如何操作可编辑iFrame文档中的文本
- 如何确保用户在iframe中执行操作