Mozilla 도움말 검색

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

자세히 살펴보기

javascript where does id element +source exist

more options

In javascript I want to find the SOURCE code that created the element. I have a variable that might be created in one of several places. The web page is dynamically modified via ajax calls. During debug I want to ask the question "where did you originate"?

Is there a function like that? Can I create one easily? If not, would it be worthy of the Firefox team?

In javascript I want to find the SOURCE code that created the element. I have a variable that might be created in one of several places. The web page is dynamically modified via ajax calls. During debug I want to ask the question "where did you originate"? Is there a function like that? Can I create one easily? If not, would it be worthy of the Firefox team?

모든 댓글 (7)

more options
more options

Unfortunately, that information -- "how exactly did this element get added to the DOM" -- is not part of the DOM itself, so I can't think of any place to access it.

It would be interesting to try to create such a feature. If I were to inject a Mutation Observer into the document to take some action every time an element were added to the DOM, I don't know how my script could determine what line in what script just did that. Looking at it from the other perspective, could the debugger be persuaded to log the relevant details each time it added an element to the DOM? This probably exists in some debugger somewhere and probably could be brought to Firefox, but... not by me.

more options

You would probably need a full stack trace to be able to see what JavaScript code got executed and what parameters were used. This would involve a very large amount of data and thus would slow down Firefox in such a way that it wouldn't be usable.

more options

jscher2000,

How about an approach where the element(s) are identified in advance? In other words, I want to know the instance source of foobar so when the various sources are processed just id/name=foobar have supplemented code generated. At execution time the extra code reports on the origin source, perhaps in a user designated variable.

more options

It's not uncommon to set a watch in a debugger, but the details are beyond my expertise.

more options

The debugger would not meet my application needs since the program would be in production.

I suppose I'm just going to need to give up on this feature request for now.

I'll find a different way.

more options

I'm not sure you should give up just yet... This support forum is not a place to get features added to Firefox; at most we can describe what's available now, what we know to be coming, the add-ons we know about, and ideas we might have. You could take your request to either or both of the following: