The current webpage can use ‘$CS.function_name’ to call some functions. I wonder how to find which js file does the ‘$CS’ come from?
CodePudding user response:
This action takes a bit of detective work. You'll have to learn how to use the debugger in the browser and dig into all included javascript files that your code uses. In those files, search for the reference of $CS and see if that is the original $CS you wish to track down. Inside that source file, assuming that include has the function, search for it. Once found, breakpoint it and then watch for it to be hit as you debug through your code. I had to do some detective work myself looking for a bug and eventually found it in a third-party javascript file. While the bug was minor, fixing it helped me come to a solution.
In Chrome, you can hit F12. A panel will open on the right which will give you many tools to use. Inside the SOURCES tab, you'll find the files that are being used on the web page. You'll find other windows below that give you the ability to put in breakpoints, watch variables as well as a plethora of other things. I would suggest googling "Debugging javascript using Chrome" and taking some lessons on how to debug a page using Chrome or other similar browsers.
CodePudding user response:
If $CS.function_name is a function being called on a page then you must be viewing the code. If it is not declared in the current file, you will find it in the imports at the top of the file. The import statement will tell you which .js file the $CS object comes from.