如何在Safari中调试嵌入式JavaScript

时间:2022-06-07 20:44:57

EDIT: Updated title to change 'inline' to 'embedded' to better reflect the nature of the question, per @dmi3y's suggestion.

编辑:根据@ dmi3y的建议更新了标题,将'内联'更改为'嵌入',以更好地反映问题的性质。

In Chrome I commonly debug JS by setting breakpoints in my JS files, but Chrome also allows you to do this with the actual Document in the case that there's inline JS (i.e. JS that isn't in a separate .js file, but rather is in a <script> tag). I can't, for the life of me, find the same functionality in Safari. Does it exist, or am I out of luck?

在Chrome中我通常通过在我的JS文件中设置断点来调试JS,但Chrome也允许你在内联JS的情况下使用实际的Document来执行此操作(即JS不在单独的.js文件中,而是在在

Apologies if this question has already been asked...I checked the search and only found this (somewhat, but not really) related question: How to debug lazily-loaded javascripts in Safari debugger

抱歉,如果这个问题已被提出......我检查了搜索,只发现了这个(有些但不是真的)相关问题:如何在Safari调试器中调试延迟加载的javascripts

1 个解决方案

#1


5  

You can do it (at least in 5.1.7 version for Windows), just go to the Scripts tab and select something like http://yoursite.com/ it shows the similar picture as Elements do, but you obviously could debug embedded JS there.

你可以这样做(至少在Windows的5.1.7版本中),只需转到Scripts选项卡并选择像http://yoursite.com/这样的东西,它显示与Elements相似的图片,但你显然可以调试嵌入式JS那里。

PS: by the way around the terminology, I usually think about inline script for something like

PS:从术语的角度来看,我通常会考虑使用内联脚本

<a ... onclick="myfunction();" />

or

<a ... href="javascript:myfunction();" />

that stuff might be used for bookmarklets or small calls.

那些东西可能用于bookmarklet或小调用。

code into script tag I use to call like embedded

代码到脚本标签我用来像嵌入式调用

it wold be interested if debugger could actually do work with inlined script?

如果调试器实际上可以使用内联脚本,它会感兴趣吗?

#1


5  

You can do it (at least in 5.1.7 version for Windows), just go to the Scripts tab and select something like http://yoursite.com/ it shows the similar picture as Elements do, but you obviously could debug embedded JS there.

你可以这样做(至少在Windows的5.1.7版本中),只需转到Scripts选项卡并选择像http://yoursite.com/这样的东西,它显示与Elements相似的图片,但你显然可以调试嵌入式JS那里。

PS: by the way around the terminology, I usually think about inline script for something like

PS:从术语的角度来看,我通常会考虑使用内联脚本

<a ... onclick="myfunction();" />

or

<a ... href="javascript:myfunction();" />

that stuff might be used for bookmarklets or small calls.

那些东西可能用于bookmarklet或小调用。

code into script tag I use to call like embedded

代码到脚本标签我用来像嵌入式调用

it wold be interested if debugger could actually do work with inlined script?

如果调试器实际上可以使用内联脚本,它会感兴趣吗?