Mozilla 도움말 검색

고객 지원 사기를 피하세요. 저희는 여러분께 절대로 전화를 걸거나 문자를 보내거나 개인 정보를 공유하도록 요청하지 않습니다. "악용 사례 신고"옵션을 사용하여 의심스러운 활동을 신고해 주세요.

자세히 살펴보기

How do I set a breakpoint on the first line of the first script in a page?

more options

Hello, everyone.

My question is the following:

I am using an inspector/debugger from the Firefox Development Tools. (Triggered by F12)

What I need is to set a breakpoint on the first line of the first 'script' tag Firefox encounters when loading a page.

The thing is, I don't know even which line in the webpage code the scripts starts at, since it is a heavily dynamic page which changes every time you reload it.

Is it possible to achieve?

Hello, everyone. My question is the following: I am using an inspector/debugger from the Firefox Development Tools. (Triggered by F12) What I need is to set a breakpoint on the first line of the first 'script' tag Firefox encounters when loading a page. The thing is, I don't know even which line in the webpage code the scripts starts at, since it is a heavily dynamic page which changes every time you reload it. Is it possible to achieve?

모든 댓글 (5)

more options

If you are talking about adding a breakpoint to Javascript, you would need to use a Javascript code bookmarklet to scan the entire page and add break; inside of the first script. Unfortunately, this wouldn't stop all of the scripts, as many web developers use multiple script blocks in HTML. Also, it probably wouldn't stop script files outside of the HTML code from loading. And it would also be a very taxing process for your code to look through an entire HTML page each time it loads.

If I may ask, for what purpose do you wish to make their modifications to the pages that you visit? There may be an addon that can achieve what you want.

Thanks.

글쓴이 Wesley Branton 수정일시

more options

Well... did you actually mean to add 'debugger();' to the code?

Generally, it seems a good idea to rewrite all 'script' tags in a page to include a breakpoint, but could you expand your answer a bit more: how do I make my script process a webpage ~before~ everything else starts to load?

My first thought is Greasemonkey, but I am not sure it can be forced to run in the exact moment when the page code has been downloaded, but has not yet been parsed.

I would also have to stop pipelining and multithreading, right?

more options

As I investigate this further, I think that what you are trying to achieve may not be possible because it would need to be loaded before the webpage is rendered in the browser.

more options

Here is a website with some further information on setting a Javascript breakpoint. The steps can be done using Firebug:

more options

Lockywolf said

My first thought is Greasemonkey, but I am not sure it can be forced to run in the exact moment when the page code has been downloaded, but has not yet been parsed.

Probably not at that exact moment:

https://wiki.greasespot.net/Metadata_Block#.40run-at

https://wiki.greasespot.net/DOMContentLoaded

Here's an old thread on StackOverflow about doing it with Firebug, but so much can change in 7 years that it may be completely obsolete: http://stackoverflow.com/questions/1938397/telling-firebug-to-break-as-soon-as-any-javascript-is-executed