NanoHttpd / nanohttpd

Tiny, easily embeddable HTTP server in Java.
http://nanohttpd.org
BSD 3-Clause "New" or "Revised" License
6.92k stars 1.69k forks source link

How to run code from a HTML function? #539

Closed SirMangler closed 5 years ago

SirMangler commented 5 years ago

Example HTML: <button onclick="myFunction()">Click me</button>

Javascript seems to do it like so: object.addEventListener("click", myScript);

My main intention is to receive input from a HTML page and execute a method, namely buttons and text input.

NoahAndrews commented 5 years ago

This has nothing to do with NanoHTTPD, and you're better off asking on StackOverflow.

That being said, there's no such thing as an "HTML function". What your example HTML will do is run the JavaScript function defined like so:

function myFunction {
    // do stuff
}
SirMangler commented 5 years ago

Thanks for your response. After some research I understand now that most websites handle that kind of action through JavaScript (which obviously isn't related to this library), which is triggered through the HTML.