Access variables in jsFiddle from Javascript console?

Casebash picture Casebash · Jan 15, 2013 · Viewed 7.2k times · Source

I created a fiddle with the following code:

var x=10;

When I try to view this in the console, I get the following:

> x
ReferenceError: x is not defined

Makes sense, as it takes Javascript to run the console. Is there a way to get this working?

Answer

Ragnarokkr picture Ragnarokkr · Jan 15, 2013

If you use Chrome or Chromium, looks at the bottom of your developer console, where the string <top frame> appears. Click on it and select result(fiddle.jshell.net). This will change the current scope of the browser and you can access to all the global variables. Also, remember to change the loading option in jsFiddle to no wrap if you want to access var variables, too.

Screenshot Chrome

UPDATE: 2014.12.01

With Firefox (34+) and the new Firefox Developer Edition, it's possibile to do the same by enabling the Select a frame as the currently targeted document extra tool into the developer tools, then click on it and select http://fiddle.jshell.net/_display/.

Screenshot Firefox