Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a Javascript Function from Console

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

like image 537
L3v3L Avatar asked Jan 29 '12 16:01

L3v3L


People also ask

How do I run a JavaScript script from the console?

To enter JavaScript statements and expressions interactively in the Console: Right-click in a webpage and then select Inspect. DevTools opens. Or, press Ctrl + Shift + J (Windows, Linux) or Command + Option + J (macOS), to directly open the DevTools console.

Can JS read from console?

However, what is not understandable is using JavaScript which runs only the browser, to get input from a systems command line. Doing this is possible using NodeJS. It will require us to use the readline() package. With this package, we can then accept user input and even output it to the console.


1 Answers

If it's inside a closure, i'm pretty sure you can't.

Otherwise you just do functionName(); and hit return.

like image 128
Kevin Ennis Avatar answered Oct 04 '22 15:10

Kevin Ennis