Is there a way to change frames in the Internet Explorer script console?
Asked Answered
S

4

11

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

enter image description here

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.

Sudden answered 4/3, 2012 at 19:30 Comment(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...Boutonniere
F
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.

Fuchsin answered 4/12, 2012 at 16:55 Comment(1)
Note that this only works in IE 9 or greater. There doesn't appear to be a way to do this in IE 8 unfortunately.Gambeson
O
8

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

Opiumism answered 2/12, 2013 at 21:51 Comment(0)
R
2

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.

Internet Explorer 11 Dev Tools Target Frame combobox

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

Reagent answered 8/7, 2015 at 15:19 Comment(0)
J
0

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.

Johniejohnna answered 4/3, 2012 at 19:33 Comment(1)
The first method doesn't work for me. Ben's cd function below is rock-solid, however.Cyclothymia

© 2022 - 2024 — McMap. All rights reserved.