Running the example from localhost, with the default search engine set
(to localhost) returns a searchBox object but it has no functionality
(code below).
Further investigation revealed that the `window.chrome.searchBox`
exists on all websites and not just the domain for the default search
engine (despite the api document saying otherwise).
Also, even with
google.com set to the default search engine in chrome
the `window.chrome.searchBox.value` and other properties appear to
have no functionality although the omnibox instant search clearly
works for chrome. Is `
google.com` using some other implementation to
interact with the omni box? If so is there a way to interface with the
functional implementation?
Reference:
http://dev.chromium.org/searchbox
I also noticed that
bing.com is able to populate the search
suggestions in the dropdown menu, but does not have instant search
interaction with the DOM. On a slightly different note, is there any
documentation to interface with the autocomplete, less the Onibox +
DOM interaction?
Example code:
var searchBox = (window.navigator.searchBox ||
window.chrome.searchBox)
searchBox.onchange = function() {
if (this.selectionStart == this.selectionEnd &&
this.selectionStart == this.value.length)
alert('Cursor is at end of input');
alert('Setting suggestions for: ' + this.value);
this.setSuggestions({
suggestions: [
{ value: "one"
},
{ value: "two"
}
]
});
}
searchBox.onsubmit = function() {
alert('User searched for: ' + this.value);
}
searchBox.oncancel = function() {
alert('Query when user cancelled: ' + this.value);
}
searchBox.onresize = function() {
alert('Resized to: ' +
[this.x,
this.y,
this.width,
this.height].join(','));
}
Thanks!