Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to coorporate with the autocomplete provided by a browser using javascript

I'm doing some demos on javascript. I regiester a onkeypress event on a text input and check that if it's "enter" key to auto submit a form. The browser has a autocomplete function (mine is firefox), which may select from a dropdown list using the up/down arrow and a enter key. The problem is that when the input text is focused and the autocomplete is shown, you press enter button just to select the autocomplete item, but it auto submits the form at the same time. How to avoid this? How can I retrieve the autocomplete element from browser using javascript ??

like image 438
waytofall Avatar asked Jan 21 '26 12:01

waytofall


1 Answers

It is not allowed. It may be regarded as a security hole if it supposed to be done on any web browser.

Suppose that your website visitor tried to search for a keyword like "p*rn" so you as a website owner able to know that user like p*rn!. It is just a little example to show the security and privacy issue that your request may be.

like image 127
SaidbakR Avatar answered Jan 24 '26 02:01

SaidbakR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!