Address Bar API


#1

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.


#2

I think this has merit however I see the following potential problems:

  • Privacy - They might be going to a different website so if your able to access what they are typing you might be able to track what they are googling or websites they are visiting, one box with multiple purposes has this issue
  • Built in behaviours - How would this compete with built in behaviours, take for example Safari on iOS one of the built in behaviours is to be able to search the current page.

I think out of the two, privacy is the biggest concern so if this can be resolved I think this could be really useful


#3

Check if input is a URL with different origin before returning input to api?


#4

This conversation is old and and the proposal is unnecessary. Website search bars can already be simple and “clean”, websites being able to know what the user is typing in the page address bar would cause privacy issues like jonthanfielding stated and the address bar shouldn’t be the place for using search engines when on a website as they are available from the website so should be used on it. The only other use of search bars in the address bar is using the browser’s capability to discover available search engines for a website typed into the address space (when not necessarily on that website) and allow the user to type a search query to be sent directly to the results page and the page displayed, such as in Google Chrome below.