Safari 和 chrome javascript 控制台多行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2465266/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 00:29:26  来源:igfitidea点击:

safari and chrome javascript console multiline

javascriptbrowserdebugging

提问by minimalpop

Firebug has a multiline feature in their console tool. Is there a way to get this functionality with the debugger tool in Safari/Chrome?

Firebug 在他们的控制台工具中有一个多行功能。有没有办法使用 Safari/Chrome 中的调试器工具获得此功能?

回答by MrBester

Shift-Enter on Windows allows multi-line entry where Option-Enter works on Mac.

Windows 上的 Shift-Enter 允许多行输入,而 Option-Enter 在 Mac 上工作。

A more fully featured editor is in the works.

功能更齐全的编辑器正在开发中。

回答by Saeed Neamati

I recommend this:

我推荐这个:

  1. Write debugger;and hit Enter, in the console tab
  2. This takes you to the Sourcestab; if not, make sure debugger breakpoints are active
  3. Now you can write whatever you want in the Sourcestab, which acts like a full IDE with features like newline and indentation
  4. Select any part of your code to run, and right-click, choose Evaluate in console
  1. 在控制台选项卡中写入debugger;并按Enter 键
  2. 这会将您带到“来源”选项卡;如果没有,请确保调试器断点处于活动状态
  3. 现在你可以在Sources选项卡中编写任何你想要的东西,它就像一个完整的 IDE,具有换行和缩进等功能
  4. 选择要运行的代码的任何部分,然后右键单击,选择 Evaluate in console

回答by Akash

For Google Chrome, you can Sources >> Snippets >> + New Snippetin the Developer Console.

对于Google Chrome,您可以Sources >> Snippets >> + New SnippetDeveloper Console.

enter image description here

在此处输入图片说明

Once you have written your multi-line code, you can execute it with the enter image description herebuttonor with Ctrl + Enteras mentioned on the button.

一旦你写你的multi-line code,你可以通过执行它 或与上提到。在此处输入图片说明buttonCtrl + Enterbutton

This is like a text-editor which has a host of keyboard shortcutswhich you can find under Settings >> Shortcutsunder Text Editor

这就像一个文本编辑器,里面有很多keyboard shortcuts你可以在Settings >> Shortcuts下面找到的Text Editor

enter image description here

在此处输入图片说明

Good Luck.

祝你好运。

回答by Tomas Andrle

http://code.google.com/p/chromium/issues/detail?id=35487

http://code.google.com/p/chromium/issues/detail?id=35487

Not yet.

还没有。

UPDATE: the status of the issue I linked to is now "fixed".

更新:我链接到的问题的状态现在是“已修复”。

回答by Scott Hyndman

Try pressing option (shift on Windows) at the same time as return. Inserts a newline on Mac.

尝试在返回的同时按下选项(Windows 上的 shift)。在 Mac 上插入换行符。

回答by Bimal

Shift + Enter seems to work in chrome browser. I am using ubuntu 12.04 as my operating system. Thanks to Mr Bester and Sam Dutton for their inputs.

Shift + Enter 似乎在 chrome 浏览器中工作。我使用 ubuntu 12.04 作为我的操作系统。感谢 Bester 先生和 Sam Dutton 的投入。

回答by S. A. Malik

It is simple ... place semicolons between your multilines and it will work in the console.

这很简单......在多行之间放置分号,它将在控制台中工作。

For example

例如

if you have html like this

如果你有这样的 html

<div id="test">This is a test statement</div>

You could paste following in the console and it will work

您可以在控制台中粘贴以下内容,它会起作用

var ourTest = document.getElementById('test'); alert(ourTest.innerHTML);

I hope it helped.

我希望它有所帮助。

回答by Piotr Galas

There is cool extension to chrome https://chrome.google.com/webstore/detail/bigconsole/klommbdmeefgobphaflhmnieheipjajm

chrome 有很酷的扩展https://chrome.google.com/webstore/detail/bigconsole/klommbdmeefgobphaflhmnieheipjajm

It just add another tab named BigConsole and it allow multiline code execution

它只是添加另一个名为 BigConsole 的选项卡,它允许多行代码执行

回答by Omar Alejandro

Try using the notepad (or someting else) and then copy/paste to the console, works for me!!!!

尝试使用记事本(或其他东西),然后复制/粘贴到控制台,对我有用!!!!