Skip to content

Instantly share code, notes, and snippets.

@RiceeeChang
Created September 27, 2017 11:33
Show Gist options
  • Save RiceeeChang/bddbbe31e1a442c2e523fd59bd9c3d49 to your computer and use it in GitHub Desktop.
Save RiceeeChang/bddbbe31e1a442c2e523fd59bd9c3d49 to your computer and use it in GitHub Desktop.
Google Custom Search Engine always let search with "intitle:"
<gcse:searchresults-only gname="results"></gcse:searchresults-only>
var term = "search_term";
var myCallback = function() {
if (document.readyState == 'complete') {
var searchResult = google.search.cse.element.getElement("results");
searchResult.execute(term);
} else {
google.setOnLoadCallback(function() {
var searchResult = google.search.cse.element.getElement("results");
searchResult.execute(term);
}, true);
}
};
window.__gcse = {
parsetags: 'onload',
callback: myCallback
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment