window.chrome.searchBox has no functionality?

208 views
Skip to first unread message

devaholic

unread,
Apr 21, 2012, 1:49:16 AM4/21/12
to Chromium-discuss
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!

PhistucK

unread,
Apr 21, 2012, 3:49:32 AM4/21/12
to tblo...@gmail.com, Chromium-discuss
Just to make sure, do you have Chrome Instant enabled? I think it is a requirement for this to work.
Go to chrome://chrome/settings/ and check "Enable Instant for faster searching (omnibox input may be logged)" under Search, then try again.
If it does not work, I am not sure how a search engine can declare the support for the instant feature...

Search suggestions and instant are somewhat unrelated.
I believe search suggestions are standardized and can be declared using the OpenSearch specifications, if I am not mistaking, which is why Bing (and others) provides them.

PhistucK




--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
   http://groups.google.com/a/chromium.org/group/chromium-discuss

devaholic

unread,
Apr 21, 2012, 4:02:06 AM4/21/12
to Chromium-discuss


On Apr 21, 2:49 am, PhistucK <phist...@gmail.com> wrote:
> Just to make sure, do you have Chrome Instant enabled? I think it is a
> requirement for this to work.

Yes of course

> Go to chrome://chrome/settings/ and check "Enable Instant for faster
> searching (omnibox input may be logged)" under Search, then try again.
> If it does not work, I am not sure how a search engine can declare the
> support for the instant feature...
>
> Search suggestions and instant are somewhat unrelated.
> I believe search suggestions are standardized and can be declared using the
> OpenSearch specifications, if I am not mistaking, which is why Bing (and
> others) provides them.

Yes.. my question is about integrating the omnibox with the dom as
mentioned here http://dev.chromium.org/searchbox -- although
`window.chrome.searchBox` exists, it appears to have no functionality,
even when using the omnibox with google.com

You can test this yourself by going opening the console in chrome,
typing some search results (and with google.com as the search engine
the DOM updates and searches as you type in the omnibox). While at the
same time calling `window.chrome.searchBox.value` in the chrome
console should AFAICT and according to the spec for `searchBox` return
the current value of your search in the omnibox but it does not.

Thanks for the reply
> > Chromium Discussion mailing list: chromium-disc...@chromium.org

PhistucK

unread,
Apr 21, 2012, 4:20:22 AM4/21/12
to tblo...@gmail.com, Chromium-discuss
Did you try to print the value every few milliseconds using setInterval or something similar?
Or perhaps only when the events are fired? Try to add listeners to the events.
It makes sense to me that these values are populated only when the omnibox has the focus, but my sense might just be insensible. ;) 

PhistucK



Chromium Discussion mailing list: chromium...@chromium.org

Thomas Blobaum

unread,
Apr 21, 2012, 4:49:41 AM4/21/12
to PhistucK, Chromium-discuss
Yes, my intuition did lead me there as well. I did not see any interaction though.
Reply all
Reply to author
Forward
0 new messages