Action Form HTML

2

Well, I recently had a question when I analyzed some forms on web sites. I'll be quite straightforward.

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

For example:

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

Instead of the actual path that would be sent:

action="/empresa/funcionarios/novo"

What is the advantage of using these actions? The only thing I thought would bring me benefits would be if a user disengaged the javascript then no communication would be established,

    
asked by anonymous 13.12.2016 / 00:21

1 answer

1

Following this setting the action attribute:

free translation:

  

This attribute specifies a form processing agent. The behavior of the user agent for a value other than an HTTP URI is undefined.

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

It's hard to answer: "Why do some HTML Forms in some web applications use javascript code in their action?"

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

In short, I only see undercuts.

    
13.12.2016 / 02:17