Developers › ODIN blog

Custom Protocol and Content Handlers in Opera 11.60

November 7, 2011 · by Mike Taylor

Custom Protocol and Content Handlers in Opera 11.60 beta

The Opera 11.60 alpha snapshot introduces support for HTML5 custom scheme and content handlers.

Not yet supported are the isProtocolHandlerRegistered, isContentHandlerRegistered, unregisterContentHandler, unregisterProtocolHandler methods which were added to the spec recently.

The idea is pretty simple. Your site can offer to handle certain MIME types or schemes (aka “protocols”) and the user has the option of opting in. One obvious use-case is webmail. For example, a service like Fastmail.fm or Gmail could tell your browser to open its "Compose" page if you click on a "mailto:" link rather than open a native mail application.

Of course, there are reasons why you wouldn’t want to pass off every type of content to a web-app—we want JavaScript and CSS to be handled by the browser, for example—so a blacklist exists. For security reasons, there's also a whitelist for schemes (but with the option to create a custom “web+” scheme).

Protocol Registration

navigator.registerProtocolHandler takes three arguments: the protocol, a URL which points to the custom handler application with a placeholder “%s”, and a title.

navigator.registerProtocolHandler(
  "tel",                           //protocol
  "/protocolhandler.html?%s",      //handler
  "Telephony"                      //title
);

In a user-agent that supports this, the user will be prompted to allow this registration to happen. Here is how this currently looks in Opera 11.60 alpha:

Once that’s taken care of, all “tel:” links will have the opportunity to be handled by this “Telephony” app. For example: clicking on tel: 555-1234 brings up a dialog asking if you would like to open the link with the just-registered application, or the default.

The browser then navigates to http://miketaylr.com/pres/capjs/demo/?tel%3A5551234. A script can then parse the URL and operate on the “tel%3A5551234” content (in this case, just put the phone number in the phone’s LED).

You can try it out here.

Content Registration

navigator.registerContentHanlder takes three arguments as well: the content-type, a URL which points to the custom content handler with a placeholder “%s”, and a title.

navigator.registerContentHandler(
  "text/x-cheeseburger",                     //content-type
  "http://miketaylr.com/code/cb.html?cb=%s", //handler
  "Cheeseburger Parser"                      //title
);

Just like registerProtocolHandler, the user will be prompted to allow the content-type registration to happen.

In this example, we have a custom text/x-cheeseburger content-type parser (see the syntax diagram) to operate on our .cheeseburger files. When we download a resource with the text/x-cheeseburger content-type, our browser will ask us to allow it to open it with our custom handler.

Again, just like registerProtocolHandler, the application is opened with the “%s” placeholder replaced by the URL of resource to be handled. In this case, http://miketaylr.com/code/cb.html?cb=http%3A%2F%2Fmiketaylr.com%2Fpres%2Fcapjs%2Fdemo%2Fsingle.cheeseburger. Now our script can fetch the contents and present it in a colorful way.

You can give it a spin here.

Readers' comments 57

Left under the original article, as archived.

  • dmcb7Friday, November 4, 2011 5:00:08 PM

    The following video link creates a repeatable crash when I attempt to go full screen;www.globalnational.com/GlobalNational/video/vlog+communist+rally+in+greece/video.html?v=2164475267&p=1&s=dd#videoe Can anyone with linux confirm. Have sent numerous crash reports for last few builds regarding this same problem.. Opera/9.80 (X11; Linux i686; U; en) Presto/2.10.228 Version/11.60This problem exists with 11.51and 12 as well.This forces one to use Firefox or Chrome.
  • ChristophFriday, November 4, 2011 5:01:32 PM

    Originally posted by Afonso1:

    Passwords SYNC _ DID NOT WORK

    Lions 10.7.2 MBP

    Opera Link - including the passwords - works perfectly here (Did you tickmark the "sync passwords"-item in the Opera Link dialog, which is disabled by default?) Win8 DevP x64
  • slalauretteFriday, November 4, 2011 5:03:45 PM

    Originally posted by MossMan:

    Ooohh... I want to keep Next (12) *and* install 11.6 builds over 11.52 - this should be fun!


    This is what will happen by default.
  • Francesco De DomenicoFriday, November 4, 2011 5:06:33 PM

    using it right now, seems safe for daily and production use, I hope we will meet stable requirements soon!
  • Afonso1Friday, November 4, 2011 5:11:07 PM

    Originally posted by christoph142:

    Originally posted by Afonso1:

    Passwords SYNC _ DID NOT WORK

    Lions 10.7.2 MBP


    Opera Link - including the passwords - works perfectly here (Did you tickmark the "sync passwords"-item in the Opera Link dialog, which is disabled by default?)
    Win8 DevP x64
    Yes I did. lets me try unistall and install again
  • Afonso1Friday, November 4, 2011 5:23:37 PM



    PASSWORD SYNC NOT WORKING _ MBP LIONS 10.7.2

    OPERA CRASHED ON OPERA PHOTO UPLOAD WITHIN OPERA

    PLS HELP
  • minhoFriday, November 4, 2011 5:33:10 PM

    I export my mail messages from opera next snapshot and import to this 11.60 snapshot, all my inbox messages are in "Sended itens" now. :cry:
    Confirm?

    win 7 x64
  • Afonso1Friday, November 4, 2011 5:40:36 PM

    Originally posted by Afonso1:

    Originally posted by minho:

    I export my mail messages from opera next snapshot and import to this 11.60 snapshot, all my inbox messages are in "Sended itens" now. :cry:
    Confirm?

    win 7 x64



    I done it over with my MACBOOK PRO all good here. Perfect in fact
    Apologies i did not IMPORT / EXPORT . I copy the folder ( make a duplicate ) from within user/library/applications support / operanext / mail and them COPY that duplicate (without the name word "copy " to the mail folder from Opera. Hope it helps.
  • BLOBOFriday, November 4, 2011 5:48:06 PM

    good decision :>
  • nesl247Friday, November 4, 2011 5:51:59 PM

    Please release a 12.00 version of this, or at least make an opera next version. I haven't in the past year run anything but Opera Next, and it is a bit annoying to either choose between bug fixes or redoing my profile.
  • Michael A. Puls IIFriday, November 4, 2011 6:01:02 PM

    registerProtocolHandler() is a little buggy.

    You can goto mail.google.com, paste the javascript URI from here into the address field and press enter to set Gmail as the mailto handler. But, it's a little buggy after a restart and Opera will crash when launching mailto URIs.
  • minhoFriday, November 4, 2011 6:12:54 PM

    Mailto links are still not working.

    win 7 x64
  • Afonso1Friday, November 4, 2011 6:15:39 PM

    Gyus apologis once again but password sync is NOT working. try a refresh install, tried changing my profile password.... NADA, 0 Nothing. Please advise
  • Satan D. LuciferFriday, November 4, 2011 6:37:00 PM

    opera:gpu needs to be erased from 11.60 snapshots/final since it wont include HWA

    just a heads up:)
  • DanStudioFriday, November 4, 2011 6:52:08 PM

    Still problems with 'Search on page' (Ctrl+F) in a textarea: if you click on the found result, the textarea's scrollbar pulls up to the top: you need manually find position of a phrase you've already found :sad:

    :bomb: :bomb: :bomb:
    i've told about this problem many times already!
  • TonyStarkAKAIronManFriday, November 4, 2011 6:55:19 PM

    Great work guys.

    Is it me or the Winamp download visual glitch/bug is still there !

    http://s7.postimage.org/fjtjxtj9n/Opera_11_6_Winamp_Download_Bug.png

    Thanks.
  • Manoj ChandrasekharanFriday, November 4, 2011 7:08:21 PM

    surprise, surprise.. Tunny!! downloading now, thanx
  • ClashCityRockerFriday, November 4, 2011 7:11:20 PM

    I'm guessing this means we won't be seeing an Opera 12 final in 2011, as why split developer time by supporting dual releases?

    Don't get me wrong. I agree with the statement that it's far more important to do things right rather than rush them, but it would be nice to back that statement up a little more.
  • minhoFriday, November 4, 2011 7:15:06 PM

    Go to http://www.terra.com.br/portal/
    Result: http://files.myopera.com/minho/albums/3631672/terra.png

    Fix before final release please. This site is a Opera partner in my country.
    win 7 x64
  • BinbiFriday, November 4, 2011 7:21:53 PM

    Hy!


    It is true that this year comes out of the opera 12?
    When expected Do Not Track?:smile:
  • minhoFriday, November 4, 2011 7:25:25 PM

    Originally posted by TonyStarkAKAIronMan:

    Is it me or the Winamp download visual glitch/bug is still there !http://s7.postimage.org/fjtjxtj9n/Opera_11_6_Winamp_Download_Bug.png


    Same here: http://www.baixaki.com.br/download/opera.htm

    Click on "Clique para baixar" green button. Old bug. :awww:
  • Robin GrolleauFriday, November 4, 2011 7:39:30 PM

    still have problems with http://www.deezer.com with the search box, and maybe more...
    And opera crash just before I submit this comment.

    Windows 7 x64
    Intel Core 2 Duo E8600
  • DrDannyFriday, November 4, 2011 7:48:56 PM

    Over-write installation added many new unwanted items to my SpeedDial. Bad form, guys....
  • ritmocafeFriday, November 4, 2011 7:57:55 PM

    Still no support for mac OS Lion gesture?
  • earth01Friday, November 4, 2011 8:04:09 PM

    Crash on publishing here :knockout:

    Windows Vista 32bits, USB installation.
  • ttaveiraFriday, November 4, 2011 8:07:23 PM

    I think the address bar should continue to show bookmarks that match the input at the top of the list. Particularly bookmarks that have a nickname associated.

    For example, I have 'desktopteam' as a bookmark nick to this blog, yet when I type 'desktopt', most of the string, I still have to press down 6 times - skipping the useless Google search results - to reach it.

    Please consider this :worried:
  • cousin333Friday, November 4, 2011 8:10:12 PM

    Nice changelog... :smile: Also good decision to split the release. I have been told a bug, that I can confirm:

    1. Open http://na.leagueoflegends.com/items -> scrolling is choppy compared to IE9
    2. Click in a checkbox in "Filters" -> 100% CPU load, VERY choppy scrolling

    Using latest build (this snapshot) on Win7.
  • Constantine VesnaFriday, November 4, 2011 8:10:44 PM

    DSK-347689 (corrupted CSS gradients) is still not fixed :sad: This is bad, because Opera 11.52 does not have it.
  • slalauretteFriday, November 4, 2011 8:26:22 PM

    Originally posted by minho:

    I export my mail messages from opera next snapshot and import to this 11.60 snapshot, all my inbox messages are in "Sended itens" now. Confirm?


    Why did you import instead of pointing your mail directory to that folder? opera:config#Mail|MailRootDirectory

    I think that if you delete the copied folder and edit that setting you will see all your mails correctly, and you'll be working with one copy instead of two.
  • Branko86Friday, November 4, 2011 8:27:17 PM

    This version crashes when I try to install this extension X-notifier (Gmail, Hotmail, Yahoo, AOL ...)https://addons.opera.com/en/addons/extensions/details/x-notifier-gmail-hotmail-yahoo-aol/0.1.9/?display=en
    I'm using Win XP Pro SP3 x86
  • slalauretteFriday, November 4, 2011 8:29:39 PM

    Originally posted by DanStudio:

    Still problems with 'Search on page' (Ctrl+F) in a textarea: if you click on the found result, the textarea's scrollbar pulls up to the top: you need manually find position of a phrase you've already found


    +1. Editing any wiki is a pain in the knuckles.
  • Marco AdrianiFriday, November 4, 2011 9:01:13 PM

    I just installed the new release on Windows 7 x86 and noted two main problems:

    1- The address bar does no more show the nicknames.

    2- In the feed-adding screen the only option to subscribe a feed is to use Opera Mail. I use Google Reader to manage my feeds and so I have to manually add new feeds through Google reader's interface.

    However, it's a very good idea to split the release 12.00 in two version.
  • Michael PetrushinFriday, November 4, 2011 9:02:03 PM

    Visited links are still disappearing after browser restart :sad:

    And yes, it's sad that I can't downgrade my profile (with mail) from 12.00 (which is pretty stable for me) to 11.60.
  • JosemeloFriday, November 4, 2011 9:27:49 PM

    Crash when closing the browser.

    Debian 6.03_64.
  • ricksperFriday, November 4, 2011 9:34:42 PM

    Is mailto: working in this build?
  • minhoFriday, November 4, 2011 9:41:04 PM

    Originally posted by ricksper:

    Is mailto: working in this build?


    No.
  • Rafael LuikFriday, November 4, 2011 9:41:34 PM

    I was expecting this release, I thought of it yesterday... Believe me or not.

    Very good move. :yes:

    Originally posted by minho:

    Originally posted by TonyStarkAKAIronMan:

    Is it me or the Winamp download visual glitch/bug is still there !http://s7.postimage.org/fjtjxtj9n/Opera_11_6_Winamp_Download_Bug.png

    Same here: http://www.baixaki.com.br/download/opera.htm Click on "Clique para baixar" green button. Old bug. :awww:
    This is not a bug. The website developers made the download to open in a very small new window. Opera open it as a new very small tab, and by having a non-modal download dialog the dialog is "trapped" inside the very small tab.
  • ricksperFriday, November 4, 2011 9:45:47 PM

    Originally posted by minho:

    Originally posted by ricksper:
    Is mailto: working in this build?
    No.


    So you will lose it if you overwrite 11.52
  • GeneticBOTFriday, November 4, 2011 9:45:54 PM

    This bug is still present in this snapshot:

    "An important bug in this site: http://www.mercadolibre.com.ar/

    Image: http://img11.imageshack.us/img11/2976/operabug.png

    The category list is not working as it should, it is supposed that you have to chose only ONE item from each column until you reach a continue buttom.

    It's a well known site for sales.

    Win 7 x64"
  • TidanFriday, November 4, 2011 10:01:45 PM

    Hello, I have trouble with Facebook for a while because of their updated home page, Facebook freezes at a time when I stay too long on its home page, I think it is wire news and chat, so if you could repair her because my cpu always hot on his version is 11.52, 11.60 or 12, its done since 2007 that I used your browser as default browser, I recommended him to all my friends in France, and I hope you will exceed the classification Firefox and Chrome browsers.
  • minhoFriday, November 4, 2011 10:04:17 PM

    I can not install any dictionary, list is empty.
    http://my.opera.com/minho/albums/showpic.dml?album=3631672&picture=131324182

    win 7 x64
  • RickFriday, November 4, 2011 10:17:04 PM

    Gmail is broken on Linux and Windows 7 with 11.60.

    Linux has been broken, Windows worked prior to 11.60.
  • Rafael LuikFriday, November 4, 2011 10:18:40 PM

    Originally posted by Fifonik:

    it's sad that I can't downgrade my profile (with mail) from 12.00 (which is pretty stable for me) to 11.60.

    You shouldn't be using testing builds as if they were stable ones and you could put all your precious data there. Also, you can't expect to have downgrade possibility on any software.
  • minhoFriday, November 4, 2011 10:21:38 PM

  • Rafael LuikFriday, November 4, 2011 10:25:10 PM

    Excuse me.

    Originally posted by Swapnil99pro:

    Does that mean that you will be releasing both Opera 11.60 and Opera 12.00 builds week-by-week.

    Originally posted by ObeseMaurice:

    You will release Opera 12.00 by the end of the year, right?

    When it's ready.

    Originally posted by Swapnil99pro:

    Opera 12 would eventually be delayed.

    It can't be delayed since it wasn't given a release date in first place! There's no promised date or anything similar.
  • berend ytsmaFriday, November 4, 2011 10:25:20 PM

    Originally posted by rskunath:

    Gmail is broken on Linux and Windows 7 with 11.60.


    What is broken? I don't see it
  • Obese MauriceFriday, November 4, 2011 10:28:10 PM

    Originally posted by rafaelluik:

    It can't be delayed since it wasn't given a release date in first place! There's no promised date or anything similar.



    Ermm, on the conference they said by the end of the year.
  • bleicherFriday, November 4, 2011 10:35:16 PM

    still cyclic 100% cpu load/freezing on
    http://forum.de.selfhtml.org/
    on Win7-64bit
  • Branko86Friday, November 4, 2011 11:07:50 PM

    What is wrong with full screen? I don't wanna see border when I click F11 for full screen. Win XP Pro SP3 x86
  • RijkFriday, November 4, 2011 11:31:02 PM

    Originally posted by rafaelluik:

    Originally posted by Fifonik:

    it's sad that I can't downgrade my profile (with mail) from 12.00 (which is pretty stable for me) to 11.60.

    You shouldn't be using testing builds as if they were stable ones and you could put all your precious data there. Also, you can't expect to have downgrade possibility on any software.
    Or, just go on using the 12.00 snapshot then, for now. There are currently no mail compatibility issues between the latest snapshots and the 11.60 build, so moving mail folders between their profiles should work fine. But don't do that unless you really know what you are doing and/or have good backups.

    Originally posted by slalaurette:

    Why did you import instead of pointing your mail directory to that folder? opera:config#Mail|MailRootDirectoryI think that if you delete the copied folder and edit that setting you will see all your mails correctly, and you'll be working with one copy instead of two.

    Only do such things if you really know what you are doing - and if you are aware that at some point the different versions might not be compatible with each other anymore.

    Originally posted by clashcityrocker:

    I'm guessing this means we won't be seeing an Opera 12 final in 2011, as why split developer time by supporting dual releases?

    Developers are split over different features, not releases. What features to package as what version is something on which plans can change, like just happened.

    Originally posted by christoph142:

    Originally posted by blackcoder:

    you are talking about program files-folder?


    Yep, C:/programs(x86)/Opera...
    However, what may be important: I wasn't able to install the USB-installation to that path either without opening the installer as administrator! Doing a normal installation works without admin rights to the same path!
    You shouldn't even try to do such things in Windows Vista or Windows 7...

Pages: 12 Next »

About this article

Published inODIN blog
DateNovember 7, 2011
AuthorMike Taylor
TagsHTML5, cheeseburgers
OriginalInternet Archive