问题
Given the following input:
<input id="residential-address" placeholder="Residential Address" autocomplete="off" type="search" />
I continue to see addresses recommended:
[![enter image description here][1]][1]
I see that my browser setting tell Chrome to autofill, but then google's own location autocomplete widget UX becomes broken (with autofill overlapping the [autocomplete][2] widget).
[![enter image description here][3]][3]
What's the proper way to go about telling the browser to back off here?
Autocomplete code (works):
var initAutocomplete = function (inputId) {
var autocomplete = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */(document.getElementById(inputId)),
{ types: ['geocode'] });
autocomplete.addListener('place_changed', function () { handleAddress(this) });
return autocomplete;
}
Setting the autocomplete="new-password" doesn't work; I see it get reverted to off on load, and autofill persists.
回答1:
Simply changing the id to NOT include address is what fixed it for me. Thanks, Google, for injecting your opinions and random features into my projects and giving me more work. Stop trying to be "clever".
来源:https://stackoverflow.com/questions/54485995/stop-chrome-from-suggesting-addresses-with-html-while-using-google-places-autofi