It would be really great if there was an API for browser’s address bar adding window.onadressbarchange
and window.onadressbarenter
events and allowing to put custom search suggestions specific for the opened site.
That could be something like the following:
[
ConstructorTemplate=Event
] interface AddressbarEvent : UIEvent {
[InitializedByEventConstructor] readonly attribute DOMString text;
void initAddressbarEvent([Default=Undefined] optional DOMString type,
[Default=Undefined] optional boolean canBubble,
[Default=Undefined] optional boolean cancelable,
[Default=Undefined] optional DOMWindow view,
[Default=Undefined] DOMString text);
};
And used like that:
window.addEventListener('addressbarchange', function(event) {
switch (event.text.charAt(0)) {
case 's':
return ["search", "save"];
case 'e':
return "edit";
}
});
window.addEventListener('addressbarenter', function(event) {
switch (event.text) {
case "save":
save();
return true;
case "edit":
edit();
return true;
default:
return false;
}
});
Maybe there should be a special meta tag defining a keyword which must be used as prefix.
This feature in future will allow to remove search bars from top of the pages on sites like Google and Facebook, providing a simpler and cleaner look.