4

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

1 Answer 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.

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?

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer pointed me in the right direction. My Scripts tab has an option called 'DOM Tree' or 'Source Code' (see this screenshot cl.ly/image/0S2S3t1F1a1Y) that was set to DOM Tree. When I changed it to Source Code, the line numbers (and ability to set breakpoints) appeared. Thanks for pointing me in the right direction. Mind if I edit to add that, or if you want to, I'll accept as soon as that's in there). Also, good point on terminology...fixing the title now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.