Basically, I want to create a login popup like the one that a lot of routers have to get access to the setup page:
What you need is a form based authentication defined in your HTML. Something like this:
and you would need a server to handle the POST action, and perform authentication.