IE7 form not requested to remember password when submitting via javascript

I have a website where we use Javascript to submit a login form. In Firefox, it prompts the user to remember their password when they log in, but this is not the case on IE7.

After some research, it seems like the user is only requested in IE7 when the form is submitted using the Submit control. I created an html sample to prove that it is.

<html> <head> <title>test autocomplete</title> <script type="text/javascript"> function submitForm() { return document.forms[0].submit(); } </script> </head> <body> <form method="GET" action="test_autocomplete.html"> <input type="text" id="username" name="username"> <br> <input type="password" id="password" name="password"/> <br> <a href="javascript:submitForm();">Submit</a> <br> <input type="submit"/> </form> </body> </html> 

The href link does not receive an invitation, but the submit button will be in IE7. Both work in Firefox.

I cannot make my site look the same with the submit button. Does anyone know how to get a confirmation prompt when sending via Javascript?

+4
source share
3 answers

Why not try connecting the submit form this way?

 <html> <head> <title>test autocomplete</title> <script type="text/javascript"> function submitForm() { return true; } </script> </head> <body> <form method="GET" action="test_autocomplete.html" onsubmit="return submitForm();"> <input type="text" id="username" name="username"> <br> <input type="password" id="password" name="password"/> <br> <a href="#" onclick="document.getElementById('FORMBUTTON').click();">Submit</a> <br> <input id="FORMBUTTON" type="submit"/> </form> </body> </html> 

Thus, your function will be called whether the link is clicked or the submit button is pressed (or the enter key is pressed), and you can cancel the feed by returning false. This may affect how IE7 interprets form submission.

Edit: I would recommend always connecting form submission this way, rather than calling submit () on the form object. If you call submit (), it will not call the onsubmit form object.

+5
source

Have you tried pasting the url in href and attaching a click event handler to submit the form and return false from the click handler so that the URL does not go to.

Alternatively a hidden submit button triggered through javascript?

+1
source

You can try using HTML <button> instead of a link or submit button.

For instance,

 <button type="submit">Submit</button> 

The <button> button tag is much simpler in style than the standard <input type = "submit">. There are some cross-browser quirks, but they are not insurmountable.

A really great article on using <button> can be found in the folder: Reopen button element

+1
source

Source: https://habr.com/ru/post/1277366/


All Articles