简体   繁体   中英

Javascript: How can I find where String.format() is declared in my web application?

I have tried in vain to locate where String.format() is declared in my web app. On some pages, it works. On others, it doesn't. Sometimes, intellisense will show it even after I've commented out every .js reference in the HEAD of my document, but, when I run the page, I get the JS error:

Error: Object doesn't support property or method 'format'

I want to know where it is because I want to use it in another one of my pages. Is there a specific syntax string I can search the entire solution for?

Try in the client code. Open the browser (I prefer IE9+), F12 to open Developer Tools, Script tab and in the right you have a search box.

Type your search criteria there in a page where format is already available.

It will open the file and show the code. In the top of the file you can see its url.

IE中的F12工具

Instead of using search, as suggested by others, just set a breakpoint at one of the calls. Then move into the call and voila, you're inside the file where it's defined.

(for example using Google Chrome inspector)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM