如何在Safari中调试嵌入式JavaScript [英] How to debug embedded JavaScript in Safari

查看:180
本文介绍了如何在Safari中调试嵌入式JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



在Chrome中我通常会调试JS通过在我的JS文件中设置断点,但是Chrome也允许您使用实际的文档来实现,如果有内联JS(即JS不在一个单独的.js文件中,而是在$ code>< script> 标签)。在我的生活中,我不能在Safari中找到相同的功能。是否存在,还是我不幸运?抱歉,如果这个问题已经被问到...我检查了这个搜索,只发现这个(有点但不是真的)相关的问题:如何在Safari调试器中调试lazily加载的javascript

解决方案

你可以做到这一点(至少在5.1.7版本的Windows中),只需转到脚本选项卡,并选择类似 http://yoursite.com/ ,它显示与元素相似的图片 do ,但你显然可以调试嵌入式JS。



PS:顺便说一句,我通常会考虑 inline 脚本,如

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

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

该东西可能用于 bookmarklets



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



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


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

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?

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

解决方案

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.

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

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

or

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

that stuff might be used for bookmarklets or small calls.

code into script tag I use to call like embedded

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

这篇关于如何在Safari中调试嵌入式JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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