如何在chrome开发人员工具或chrome中使用firebug lite进入iframe?

时间:2011-04-19 05:58:27

标签: javascript firebug google-chrome-devtools firebug-lite

当我尝试cd时,控制台说“cd未定义”

2 个答案:

答案 0 :(得分:14)

在Chrome Devtools中,“上下文切换器”位于页面底部。查看<top frame>下拉列表?在那里,您可以更改脚本执行的位置。这有效地与cd()相同。

https://stackoverflow.com/a/8581276/89484

详细说明了这一点

答案 1 :(得分:6)

是的,你是对的Firebug有这个很棒的命令。我很喜欢。这让iframes更加容易。就个人而言,我之所以不去Firefox只是因为cd()可用,因为我可以在chrome dev工具中用cd做任何事情。

只需在命令提示符中使用contentWindow关键字即可访问iframe window对象。那么你将很好地访问那里的任何功能和变量。

例如,我的iframe中的变量通常无法通过控制台访问。

但我仍然可以通过contentWindow访问变量,如下所示:

theIfraem.contentWindow.secret;

enter image description here

如果要触发某个功能,请执行以下操作:

theIframe.contentWindow.myfunc();

如果你想定义一些变量(最难的):

var script = document.createElement('scrept');
script.innerHTML = "var secret = 'hi'";
theIframe.contentWindow.document.body.appendChild(script);

cd()实际上是这样做的。我知道它不如Firebugs cd()好。但好消息是cd() is coming to Chrome

相关问题