24168

Is there any way to access browser form field suggestions from JavaScript?

Is there any way to access the autocomplete suggestions that appear under HTML input fields in some browsers (representing previously submitted data)? Is this only available to the browser?

I ask as I want to make my own autocomplete implementation in javascript, but I want to intermingle my own suggestions with the users previous searches. A bit like how youtube does (but youtube stores all the data obviously, and it is tied to a login, there are no accounts on my website and never will be).

I was wondering more if there was a way to do it with the data stored in the users browser rather than storing all the data on my server. Is there is a way to grab the data the browser uses to present previous input to a user?

Answer1:

Is the data that appears in html input fields representing previously submitted data only available to the browser?

Yes - until it appears in the DOM.

Is there is a way to grab the data the browser uses to present previous input to a user?

It's a browser-specific feature, and you can't access the data [history] directly (Where do browsers save/store auto fill data). You only can disable storing anything.

I ask as I want to make my own autocomplete implementation in javascript, but I want to intermingle my own suggestions with the users previous searches. I was wondering more if there was a way to do it with the data stored in the users browser rather than storing all the data on my server.

Especially if you want to utilize all previous searches, the browser's autofill doesn't help you anyway. But yes, you can store them in the browser (on the client side) manually: Use DOM Storage, like localStorage. Though I would recommend sessionStorage only, you might run into privacy issues otherwise if everybody using a browser could see the search terms of previous users…

Answer2:

You can use jstorage. Jstorage lets you store up to 5Mb of data on the client side.

<script src="//cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js"></script> <script src="https://raw.github.com/andris9/jStorage/master/jstorage.js"></script> <script> /* $.jStorage is now available */ // store some data $.jStorage.set('yourkey', 'whatever value'); // get the data back value = $.jStorage.get('yourkey'); </script>

Answer3:

The only way i see this working is with help of localStorage (html5) problem that it doesn't work in ie<8

Here's an example: http://jsfiddle.net/8NZY7/

Recommend

  • Swift Generic Factory: Bug?
  • Spring Batch thread-safe Map job repository
  • What is the difference between GetComponent ().enabled and .SetActive (false); in unity
  • Sharepoint change Content Type in Sharepoint Designer using workflow
  • Google API - Redirect URI mismatch error
  • Excel not inserting leading zero
  • Meteor: Block access to application if user's email is not verified
  • Youtube Video Player Fullscreen click event
  • LINQ to Entities does not recognize the method 'System.String ToString()' method, and this
  • calling a fragment from fragment
  • Passing information to server-side function in a Google Docs Add On
  • MVC - @Html.CheckBoxFor
  • (Tcl/Expect) clear screen after exit
  • What's the syntax to inherit documentation from another indexer?
  • Flash radiobutton: how do I get the selected radiobutton?
  • what makes a request a new request in asp.net C#
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • How to autopopulate a field in SugarCRM form
  • nodemcu custom firmware build problems
  • Differences in dis-assembled C code of GCC and Borland?
  • Keep this build forever option - Jenkins
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Converting a WriteableBitmap image ToArray in UWP
  • Ionic 2 storage is not cleaning up on uninstall - Only for signed APK
  • Django rest serializer Breaks when data exists
  • Typescript - Unable to get 'import' statement to function
  • Recording logins for password protected directories
  • Get one-time binding to work for ng-if
  • Resize panoramic image to fixed size
  • Volusion's generic SQL folder, functionality
  • Hazelcast - OperationTimeoutException
  • jQuery tmpl and DataLink beta
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Getting error when using KSoap library to consume .NET web services
  • How do you join a server to an Active Directory (domain)?
  • coudnt use logback because of log4j
  • Authorize attributes not working in MVC 4
  • Busy indicator not showing up in wpf window [duplicate]
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF