0

Is it possible to get all the necessary information to log in using javascript?

I have a form object:

var form = getForm(); //some special function :-)
console.log(form.action); // "https://example.com/login"
console.log(form.method); // post
//next step get inputs for login name and psw, for example: name and ps

So, I can simulate post

https://example.com/login
post
name: admin
psw: harrypotter

BUT! Some web pages have another secret attribute stored in form html, like this:

action: login

I am looking for some automated method which can extract all informations need for login.

Do you have some idea how??

Thanks for any help.

1 Answers1

0

You can use iteration to look at all of the properties of a element. You can then save these values to an array and then access the array to find values, such as action.

for (var i = 0; i < elem.attributes.length; i++) {
    var attrib = elem.attributes[i];
    if (attrib.specified) {
        console.log(attrib.name + " = " + attrib.value);
    }
}

Reference: https://stackoverflow.com/a/828330/5287820

wpgbrown
  • 40
  • 9