How to let Google detect a site search engine? - google-chrome

Google Chrome has a feature where you can hit tab to search a site. Chrome then navigates to the site's own search engine and runs the inputted query. The Chrome documentation indicates that this is only available if Google has detected a search engine on the site you are trying to search.
This indeed seams to be the case, because writing stackoverflow.com<Tab>test<Enter> makes Chrome navigate here while facebook.com<Tab>test<Enter> does nothing because the tab-key tabbes out of the address line.
What I'm wondering is then how to indicate to Google that my site has a search engine and how Google needs to format a query in order to redirect a Chrome user correctly to my site when the tab-search feature is utilised. Is it a Meta tag? Is it in robots.txt?

After a little digging I found this page that describes this. Also you can read in Stackoverflow's source code and find this line of code:
<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">
What it does is indicate to Google that the description for how to use your search engine in the file /opensearch.xml which contains this:
<?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>Stack Overflow</ShortName>
<Description>Search Stack Overflow: Q&A for professional and enthusiast programmers</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">http://sstatic.net/stackoverflow/img/favicon.ico</Image>
<Url type="text/html" method="get" template="http://stackoverflow.com/search?q={searchTerms}"></Url>
</OpenSearchDescription>

When I implemented a search function for my online Klingon dictionary, I found that I didn't need an OpenSearch description for Chrome to autodetect it as a search engine.
NOTE: While this is a simpler method, it does not allow for advanced features like specifying a search template, a custom favicon (Chrome automatically uses the favicon of the site) etc. It also might not work for other browsers than Chrome.
I started off with the instructions here Search Engine Autodiscovery: Google Chrome Autodiscovery, which say:
Interestingly the auto discovery only works if the search engine is at the homepage. You have to have either an input field of the type search or of the type text with the name s:
<form>
<input type="search" name="s" />
</form>
or
<form>
<input type="text" name="s" />
</form>
I got Chrome to autodetect the search engine on my website klingonska.org without using an OpenSearch description.
However I deviated from the above description, as I found I didn't need have to have field called s nor use type="search". My final <form> look something like this (in reduced form).
<form method=get action="dict/">
<input name=q placeholder="Search dictionary…">
<button type=submit>Search</button>
</form>
The cruicial factors seemed to be that the form was located on the root page http://<domain>/ page (not a subpage like http://<domain>/<dir>/<something>.html). And, IIRC, that the search form contain only a single field.

Related

Replicate Google's "I'm Feeling Lucky" Button On My Own Site -- To Take User to Top Search Result Automatically

I am trying to replicate Google's I'm feeling lucky button.
But when I click the button it takes me to " Redirect Notice" page.
My code is as below:
<form action="https://google.com/search">
<input type="text" name="q">
<input type="submit" value="Google Search">
<input type="submit" name = btnI value="I'm Feeling Lucky">
</form>
TLDR: Just use DuckDuckGo. You typically don't care about what search engine is doing the redirecting, so long as you land on the top-result for a search term and the page for that result loads (and not a redirect page of the search engine).
https://duckduckgo.com/?q=%5Csoybeans
This URL above will redirect to...
https://en.wikipedia.org/wiki/Soybean
The %5c code above is the indicator for loading the page directly without search results (similar to the BtnI of Google).
Details on the Redirect Page from Linking to Google's "I'm Feeling Lucky"
Oct. 2, 2019: The redirect page was first reported on Google Search Help, the question has since been closed and comments are disabled -- they are probably not going to fix this.
You cannot use an <iframe />. Loading <iframe src="https://www.google.com/" /> has always loaded blank for me for the past ten years.
Likewise, you cannot use XMLHttpRequest, which I just tried, because CORS will block you out, and most browsers do not allow XMLHttepRequest.setHeader("origin", "http://www.google.com/");, otherwise, you could simply get the redirect page, parse for the first URL, and load that page. We know this is the case, because doing this following in a terminal will bypass the redirect page (thanks to Metamorphic for discovering this):
w3m -header "Referer: http://www.google.com/" "https://www.google.com/search?btnI=1&q=soybeans"
Iframes don't work, XmlHttpRequest doesn't work, and the main post on the Google Search forums for this topic has been closed and locked. I think it's obvious you'll need to find a different approach -- i.e., like a different search engine.
The %5c code above is the indicator for loading the page directly
without search results (similar to the BtnI of Google).
I've been looking all over the place for this, thank you!

Fill field value while page is loading in HTML Page

I have a third part web address (www.samplespage.com). I call this page from another web site. is it possibe to fill some field values before page load or after page load? I tried vith URL parameters but It did not work.
www.samplespage.com?id=fieldId&value=fieldValue
This is how it looks like in codes. (I picked up from source via F12 Development tools in IE)
<input name="fieldName" id="fieldId" size="12" maxlength="11" value="">
When It's an HTML page It works with URL parameters otherwise You need to use like Selenium or Ptyhon ..

chrome omnibox how to add the search on domain

How one configure his web site to let users search only on his domain using omnibox?
Example:
type youtube.com then press tab
or type yahoo.com then press
trying with vimeo wouldn't work
I didn't find anyhing in the source code.
Yes it's possible.
I did this for my blog.
<link rel="search" type="application/opensearchdescription+xml" title="The Sheng Blog" href="/resources/opensearch.php"/>
opensearch.php looks likes this:
<?xml version="1.0"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>The Sheng Blog (Beta)</ShortName>
<Description>The Sheng Blog Search</Description>
<Developer>Sheng Slogar</Developer>
<LongName>Search the entire Sheng Blog</LongName>
<InputEncoding>UTF-8</InputEncoding>
<OutputEncoding>UTF-8</OutputEncoding>
<Query role="example" searchTerms="code"/>
<SyndicationRight>open</SyndicationRight>
<AdultContent>false</AdultContent>
<Language>en-us</Language>
<Contact>contact#theshengblogg.comule.com</Contact>
<Tags>code posts tutorials ideas playground</Tags>
<Image width="16" height="16" type="image/x-icon">data:/ico;base64,AAABA...(Icon in base64)</Image>
<Url type="text/html" template="http://theshengblogg.comule.com/search.php?s={searchTerms}"></Url>
<Url type="application/x-suggestions+json" method="GET" template="http://theshengblogg.comule.com/autocomplete.php?search={searchTerms}&json=true"/>
</OpenSearchDescription>
I learned this from http://www.opensearch.org/Specifications/OpenSearch/1.1. The autocomplete part is optional. Return it in JSON format.
For example, if you search "a", return ["a","about","across","all","and"]. (Notice I put your query in the array as item 0.)
My autocomplete only seems to work in Firefox. This might be something with my sub domain.
I also couldn't get it to work in IE or Chrome.
http://dev.chromium.org/tab-to-search has the information on how to do it, potentially you could use a chrome addon to force the page to have the needed code for this to function, but I'm not sure how well such would work.

Activate a search on another website

I am trying to embed the search forms of two other sites into my own site. Here is my site, the forms are at the bottom: http://dsa.dartmouth.edu/.
The DGD search works fine - the user gets directed to the search results page - but the Course Picker one doesn't - the user just gets redirected to a blank search page.
This is my form code:
<form action="http://coursetown.hacktown.cs.dartmouth.edu/search" method="post" class="appSearch">
<input id="search" name="query[title]" placeholder="course title(s)" type="text" role="textbox">
<input type='submit' name='commit' type="submit" value='Search' />
</form>
Is there a way to make it so that the user gets directed to coursetown's search results page when they click search?
The search form on http://coursetown.hacktown.cs.dartmouth.edu/search submits by AJAX so there is no search URL to hit. Furthermore, it seems to use a hidden "authenticity_token" field, which is probably generated server-side on load so you probably need to find out if they have an API you can use for this.
If you can edit that page directly to trigger the search by JavaScript based on URL parameters that would be an option too, not sure what level of control you have over the search page.

Passing HTML form data in the URL on local machine (file://)

I'm building a small HTML/JS application for primary use on local machine (i.e. everything is accessed via file:// protocol, though maybe in the future it will be hosted on a server within intranet).
I'm trying to make a form with method="get" and action="target.html", in the hope that the browser will put form data in the URL (like, file://<path>/target.html?param1=aaa&param2=bbb). However, it's not happening (target.html opens fine, but no parameters is passed).
What am I doing wrong? Is it possible to use forms over file:// at all? I can always build the url manually (via JS), but being lazy I'd prefer the browser do it for me. ;)
Here is my sample form:
<form name='config' action="test_form.html" method="get" enctype="application/x-www-form-urlencoded">
<input type="text" name="param1">
<input type="text" name="param2">
<input type="submit" value="Go">
</form>
It might be some browser specific restriction. What browser are you using?
I tested this in Firefox 3.6.3 and Internet Explorer 8, and it works just fine.
Ok, that was stupid. The controls of my form are generated dynamically (via JS), and the generation function was setting ids for them, but not names. So, from the form's point of view, there was no parameters at all.
Thanks to Guffa for providing me a nudge in the right direction!