开发者

Detect the origin of dynamic text in JavaScript

Is there a way to detect from where the text come (if it's not pure HTML) for example

document.write ('ok') will write ok somewhere in the page. But it doesn't show up in HTML,开发者_如何学运维 it's dynamic.

My problem is that I want to know where 'ok' comes from, when I have a long/complicated source of code.

Any idea?


You can override document.write and trace where the call is coming from. For example

document.write = function(arg) {
    console.trace()
}


Search for 'ok' in your JavaScript files / look at what selector(s) it's within and search for those?

If those strategies don't help then I'm sure there's a JavaScript debugger that'll let you step through the code execution? That I expect would take a while though on your long/complicated source.

I don't think there's any other programmatic way for you to do this unfortunately.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜