Change Safari 6 console context to iframe on page

I know that Chrome allows you to choose the context for running the console with a drop-down menu and Firebug allows you to cd() in an iframe. I cannot figure out how to change the context in the Safari console. Does anyone know how to do this?

+7
source share
2 answers

Safari, unlike chrome and firefox, does not have real support for this function, and the only option is to access the window object from the console. Since you correctly indicate that this will cause problems with cross-domain policies, however, provided that you are working on a Mac (for some reason this does not work on Windows), you can use

 open -a '/Applications/Safari.app' --args --disable-web-security 

to get around this. And then on your jsbin you can use something in the lines

 window.frames[0] 

to access the page window. As far as I can see, there is no similar solution for windows, since

 Safari.exe --disable-web-security 

apparantly not working.

+8
source

The iframe itself is of type Window inside the console

 <iframe id="frame" src="about:blank"/> 

In the Safari console, you just work with

 frame.document.write('bla'); 

note that 'frame' is short for document.getElementById('frame')

0
source

All Articles