从Javascript控制台访问jsFiddle中的变量? [英] Access variables in jsFiddle from Javascript console?

查看:399
本文介绍了从Javascript控制台访问jsFiddle中的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码创建了小提琴

  var x = 10; 

当我尝试在控制台中查看此内容时,我得到以下内容:

 > x 
ReferenceError:x未定义

有道理,因为需要Javascript才能运行安慰。有没有办法让这个工作?

解决方案

如果您使用Chrome或Chromium,请查看开发者控制台的底部,其中出现字符串< top frame> 。单击它并选择 result(fiddle.jshell.net)。这将更改浏览器的当前范围,您可以访问所有全局变量。另外,如果您想要访问 var 变量,请记住将jsFiddle中的加载选项更改为 no wrap 。 / p>



更新:2014.12.01



使用Firefox(34+)和新的Firefox开发人员版本,可以做到这一点通过在开发人员工具中启用选择一个框架作为当前目标文档额外工具,然后单击它并选择 http://fiddle.jshell.net/_display/




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?

解决方案

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.

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

这篇关于从Javascript控制台访问jsFiddle中的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆