Chrome开发人员工具错误地将控制台日志字符串输出解释为链接

时间:2014-09-10 14:40:16

标签: string hyperlink google-chrome-devtools console.log interpretation

当您使用console.log显示字符串时,Chrome会将字符串的某些部分解释为链接,并相应地修饰控制台输出。如何防止这种情况?以下是演示此问题的示例。请注意,尽管第二个console.log语句的输出中没有链接,但Chrome仍然会将其中的一部分解释为超链接。

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>

<p id="jedi_mind_trick">This is not the demo you are looking for. Move along!</p>

</body>
<script>
function example() {
  var test = {data:$('#jedi_mind_trick').html(),obi_wan:"kenobi"};
}
console.log(typeof example, example);
console.log(typeof example.toString(), example.toString());
</script>
</html>

1 个答案:

答案 0 :(得分:0)

对于可能遇到此问题的任何其他人,我发现了一种避免开发人员控制台日志输出链接修饰功能的解决方法。只需使用chrome devtools copy命令将原始输出复制到剪贴板,如下所示

copy(example.toString());