Skip to content

Instantly share code, notes, and snippets.

@maxim75
Created May 19, 2011 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxim75/980216 to your computer and use it in GitHub Desktop.
Save maxim75/980216 to your computer and use it in GitHub Desktop.
Add autocomplete to text field on any website with bookmarklet
(function(){
var css_selector = 'input.tinput';
var type = '/location/australian_suburb';
if (!(window.jQuery)) {
script = document.createElement( 'script' );
script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js';
document.body.appendChild(script);
link = document.createElement( 'link' );
link.type = 'text/css';
link.rel = 'stylesheet';
link.href = 'http://freebaselibs.com/static/suggest/1.3/suggest.min.css';
document.body.appendChild(link);
script2 = document.createElement( 'script' );
script2.src = 'http://freebaselibs.com/static/suggest/1.3/suggest.min.js';
script2.onload=startJQuery;
document.body.appendChild(script2);
}
else {
startJQuery();
}
function startJQuery() {
jQuery.noConflict();
jQuery('head').append('<style>.fbs-pane { z-index: 1000; }</style>" />');
jQuery(css_selector).suggest({type:type});
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment