firebug: how to cd to an iframe

流过昼夜 提交于 2019-12-02 15:39:31

use one of these commands:

 cd(frames[0]) 
 cd(frames["iframe_canvas"])

and

 cd(top)

to return to the main window.

Still, due to a bug this currently doesn't work on cross-domain-iframes (http://code.google.com/p/fbug/issues/detail?id=3893). There are two test cases where you can test your evironment for both cases:

Another possible source of surprise: if you execute more commands at once the cd command seems to not have an effect for the directly following commands:

 >>> cd(frames[0]); location.href;
 ["Current window:", Window cdFrame.html]
 "https://getfirebug.com/tests/content/commandLine/cd.html"
 >>> location.href
 "https://getfirebug.com/tests/content/commandLine/cdFrame.html"

In Chrome there is a dropdown at the bottom top* of the javascript console that lets you switch to a different frame to execute javascript in. Works cross-domain too!

*Updated 2/10/14: In more recent versions of Chrome, this dropdown has been moved from the bottom to the top of the console.

Elements can be accessed as follows: window.frames[x].document.getElementById("elementID"); where x would be the frame index and elementID is the element you are pointing to.

I guess the wiki was not updated back when this question was asked, but now it has nice examples: https://getfirebug.com/wiki/index.php/Cd

Basically, what you were missing to get the window from the iframe element was ".contentWindow"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!