How to include JavaScript file or library in Chrome console?

后端 未结 10 1860
广开言路
广开言路 2020-11-27 08:58

Is there a simpler (native perhaps?) way to include an external script file in the Google Chrome browser?

Currently I’m doing it like this:

document.         


        
10条回答
  •  温柔的废话
    2020-11-27 09:38

    If you're just starting out learning javascript & don't want to spend time creating an entire webpage just for embedding test scripts, just open Dev Tools in a new tab in Chrome Browser, and click on Console.

    Then type out some test scripts: eg.

    console.log('Aha!') 
    

    Then press Enter after every line (to submit for execution by Chrome)

    or load your own "external script file":

    document.createElement('script').src = 'http://example.com/file.js';
    

    Then call your functions:

    console.log(file.function('驨ꍬ啯ꍲᕤ'))
    

    Tested in Google Chrome 85.0.4183.121

提交回复
热议问题