Calling a Javascript Function from Console

后端 未结 5 2052
礼貌的吻别
礼貌的吻别 2020-12-23 16:18

In Chrome\'s JavaScript console, how do I call a function that belongs to a .js file included in the webpage I am viewing?

5条回答
  •  自闭症患者
    2020-12-23 16:37

    This is an older thread, but I just searched and found it. I am new to using Web Developer Tools: primarily Firefox Developer Tools (Firefox v.51), but also Chrome DevTools (Chrome v.56)].

    I wasn't able to run functions from the Developer Tools console, but I then found this

    https://developer.mozilla.org/en-US/docs/Tools/Scratchpad

    and I was able to add code to the Scratchpad, highlight and run a function, outputted to console per the attched screenshot.

    I also added the Chrome "Scratch JS" extension: it looks like it provides the same functionality as the Scratchpad in Firefox Developer Tools (screenshot below).

    https://chrome.google.com/webstore/detail/scratch-js/alploljligeomonipppgaahpkenfnfkn

    Image 1 (Firefox): http://imgur.com/a/ofkOp

    Image 2 (Chrome): http://imgur.com/a/dLnRX

提交回复
热议问题