Reputation: 7392
I open Chrome DevTools for a remote web site (not my localhost) and select "Add folder for workspace" under "Sources". In the added folder I have a few .js files.
When I try to execute a function from one of the files in the console, eg. the function "myMethod", I get "Uncaught ReferenceError: myMethod is not defined".
How do I run my own code-files side by side with the ones already loaded into the browser?
Upvotes: 1
Views: 113
Reputation: 6768
Adding a folder to Chrome Devtools allows you to edit files from chrome, but it doesn't include them to the current web page at all. To do that, you have to actually paste the code in the console, or append a new script node referencing the file. But this has nothing to do with Chrome Devtools.
document.body.appendChild((s=document.createElement('script'),s.src='myfile.js',s));
(replace myfile.js with the complete path to the file on your pc)
Upvotes: 3