Search code examples
javascriptinternet-explorer-9script-console

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


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.


Solution

  • 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.