Action Form HTML

Asked

Viewed 134 times

2

Guys, recently I came across a question when I analyzed some forms on websites. I’ll be very direct.

Because some HTML forms in some web applications use a javascript code in their action,

For example:

action="javascript:sendForm('parametros');"

To instead of the real way that would be sent:

action="/empresa/funcionarios/novo"

What is the advantage of using these actions? The only thing I imagined would benefit me would be if a user disabled javascript so no communication would be established,

1 answer

1


Following this definition of attribute action :

free translation :

This attribute specifies a form processing agent. User agent behavior for a value other than an HTTP URI is undefined.

In my understanding this process takes place through a server-side language, even if you use javascript for this (maybe with Node.js), there is the event onsubmit.

It’s hard to answer : "Because some HTML forms in some web applications use a javascript code in their action ?"

If it is in the action, will know... It does not seem appropriate to invoke javascript functions in the attributes html standard, for this javascript has the whole range of events on*.

In short, I see nothing but frenzies.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.