OpenSearch description document discovery and Chrome
Asked Answered
L

3

9

I'm trying to figure out how to advertise my web application's search endpoint using OpenSearch (see http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document), but even my simplest example does not work. I have index.html with:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
    <head profile="http://a9.com/-/spec/opensearch/1.1/">
        <link title="Search" rel="search" type="application/opensearchdescription+xml" href="osdd.xml"/>
    </head>
    <body>
        hello
    </body>
</html>

And osdd.xml containing:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
    <ShortName>test</ShortName>
    <Description>test</Description>
    <Url type="text/html" template="http://example.com?q={searchTerms}"/>
</OpenSearchDescription>

But nothing appears to work. Chrome's "tab to search" behavior does not show up, and using the developer tools Chrome does not seem to be loading osdd.xml at all.

Any clues?

Lemmie answered 27/12, 2011 at 23:38 Comment(1)
The mime type application/opensearchdescription+xml is not IANA registered and it's not prefixed with x-. This might be the problem.Bombastic
L
7

Loading of the osdd.xml does not show up on the Developer Tools > Network tab.

http://code.google.com/p/chromium/issues/detail?id=58801#c3 (comment 3) mentions that you need to search at least once to add the search engine.

I also discovered that you need to delete existing search engines from the Settings > Manage Search Engines and restart the browser to see effects of changes to the osdd file.

Layoff answered 31/1, 2012 at 23:50 Comment(0)
M
3

Sorry for digging up this thread but I had a similar issue and managed to resolve it, so I leave my findings here if anyone finds it.

In my case, the XML file wasn't on UTF-8 thus not being correctly loaded by Chrome. Please ensure your file is on UTF-8.

Cheers!

Moberg answered 14/5, 2015 at 14:38 Comment(2)
If by this you mean the file starts with something like <?xml version="1.0" encoding="UTF-8"?>, then this did not help me. Firefox detects my open search file, but Chrome still does not.Arsenide
I was not talking about that. I was talking about the actual file encoding. In my case, if I recall this correctly, my file was saved on ANSI instead of UTF-8. After converting it to UTF-8 it worked.Moberg
H
0

Adding some more recent info here. I couldn't find any formal proof for it, but it seems like Chrome on Android changed the logic of when to show a new search engine in the settings, somewhere in September 2018. Before that, it used to work when the user simple navigated to the site. After this change, the search engine didn't show up immediately in the settings. I was able to make it work, if I go to my site that has open search meta tag. Then go to another site, and then come back. It only showed up on the second time. To make it easier for the user, I add a hidden iframe, that redirects to another site (which I control), and on that site I added a redirect back to the original site, after 2 seconds. It seems to work on all the devices I tested (a few samsung devices).

I saw comments here that says that the opensearch doc will only be looked for when the user is at the root node (mysite.com/ but not mysite.com/foo). My site is following this comment, and I didn't try otherwise, so I can't approve or deny if this is important.

Hedjaz answered 2/10, 2018 at 11:37 Comment(1)
I can confirm the comments about the root node requirement: When tested today w/ Chromium 86.0.4240.198, it would only load the opensearch xml if the search form was provided by example.org/ but not example.org/file nor example.org/dir/Spooky

© 2022 - 2024 — McMap. All rights reserved.