admin管理员组

文章数量:1297237

In Google Chrome's Dev tools there's a simple dropdown to choose which window you want to execute your script in:

Is there an equivalent in Internet Explorer? I'm trying to run scripts from the console as if they're from an iframe, not the toplevel window.

In Google Chrome's Dev tools there's a simple dropdown to choose which window you want to execute your script in:

Is there an equivalent in Internet Explorer? I'm trying to run scripts from the console as if they're from an iframe, not the toplevel window.

Share Improve this question asked Mar 4, 2012 at 19:30 Tom LianzaTom Lianza 4,0724 gold badges43 silver badges50 bronze badges 1
  • 1 He's asking for a convenience feature in IE.. Hahahaha. Sorry... Had another 4 hour "Damn-IE-is-not-working-while-every-other-browser-is" session today... – nfechner Commented Mar 4, 2012 at 19:33
Add a comment  | 

4 Answers 4

Reset to default 14

It is possible, however it’s significantly less convenient than in Chrome.

If you’re able to get a reference to the frame or its window object (using, e.g.: document.getElementById(xxx).contentWindow), you can use the console’s special cd function. This is documented here: http://msdn.microsoft.com/en-us/library/ie/gg589530(v=vs.85).aspx#UsingCDacrossFrames

Annoyingly, this means that if you want to get a reference to a nested iframe, you have to do this inside each each of the parents of the frame that you’re interested in. Debugging in IE is, erm, fun.

To follow-up on Ben's answer, that would be

cd([reference])

or

cd(frames[n])

where n is a valid index in the window.frames array

The feature is now available in IE 11. If you open the dev tools (F12) there's a combo-box in the top right that lets you select the target frame.

(Note: this is on IE 11.0.9600.17728, not sure if every version of IE 11 has it.)

F12 -> script -> choose your page -> console

EDIT:

You can start debug there on java script, add break point and stuff. your keys to run the debugger is like in visual studio.

本文标签: javascriptIs there a way to change frames in the Internet Explorer script consoleStack Overflow