Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy Chrome Extension wont return Google Search API results?
    primarykey
    data
    text
    <p>I am building this Google Chrome extension that will override Chrome Browser homepage with custom google search engine.</p> <p>This custom google search engine suppose to returns the result from the query that the user entered. To test this, i first build the html version of this custom search engine first and it works well. Below is the screenshot :</p> <p><img src="https://i.stack.imgur.com/Yfg06.png" alt="enter image description here"></p> <p>But when i tried to make it as the chrome extension, it fails with no search results being returned. </p> <p><strong>here is my main.html :</strong></p> <pre><code>&lt;HTML&gt; &lt;HEAD&gt; &lt;script type="text/javascript" src="jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;script src="search.js" type="text/javascript"&gt;&lt;/script&gt; &lt;TITLE&gt;Search or Share&lt;/TITLE&gt; &lt;link rel="stylesheet" type="text/css" href="main.css" /&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;center&gt; &lt;div id="page-wrap"&gt; &lt;div style="height:30px"&gt;&lt;/div&gt; &lt;center&gt; &lt;div id="logo"&gt;&lt;img src="logo.png" /&gt;&lt;/div&gt; &lt;input type="text" title="Real Time Search" id="searchbox" name="searchbox"/&gt; &lt;/center&gt; &lt;br/&gt;&lt;br/&gt; &lt;div id="search-content"&gt; &lt;div class="content" style="width:600px; display:inline"&gt; &lt;div class="header"&gt;Web&lt;/div&gt; &lt;div class="data" id="web-content"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/center&gt; &lt;div id="footer"&gt; Copyright &amp;copy; 2013 &lt;/div&gt; &lt;/BODY&gt; &lt;SCRIPT src="main.js"&gt;&lt;/SCRIPT&gt; &lt;/HTML&gt; </code></pre> <p><strong>and here is my manifest.json :</strong></p> <pre><code>{ "name": "Search or Share", "version": "0.2", "incognito": "split", "background": { "scripts": ["jquery-1.9.1.js","search.js","main.js"] }, "permissions": [ "http://www.google.com/*" ], "chrome_url_overrides": { "newtab": "main.html" }, "manifest_version": 2 } </code></pre> <p><strong>here is my search.js</strong> :</p> <pre><code>google.load('search','1'); </code></pre> <p><strong>and this last one is my main.js file :</strong></p> <pre><code>// Define variables var webSearch; var lastSearch = 0; //Init function $(function () { webSearch = new google.search.WebSearch(); webSearch.setSearchCompleteCallback(this, webSearchComplete, [webSearch, lastSearch]); $('#searchbox').focus(); }); // Begin search on keyup (realtime) $('#searchbox').keyup(function () { var query = $(this).val(); search(query); }); // Search for the query function search(query) { if (query.length &gt; 0) { $("#search-content").show(); } else { $("#search-content").hide(); } webSearch.execute(query); } function webSearchComplete(searcher, searchNum) { var contentDiv = document.getElementById('web-content'); contentDiv.innerHTML = ''; var results = searcher.results; var newResultsDiv = document.createElement('div'); newResultsDiv.id = 'web-content'; for (var i = 0; i &lt; results.length; i++) { var result = results[i]; var resultHTML = '&lt;div style="height:70px; margin-top:5px;"&gt;'; resultHTML += '&lt;a href="' + result.unescapedUrl + '" target="_blank"&gt;&lt;b&gt;' + result.titleNoFormatting + '&lt;/b&gt;&lt;/a&gt;&lt;br/&gt;' + result.content + '&lt;div/&gt;'; newResultsDiv.innerHTML += resultHTML; } contentDiv.appendChild(newResultsDiv); } </code></pre> <p>*i have made the jsapi.js script too, but it is too long so i dont post it here.</p> <p>Why is this happening? is it because chrome wont allow any interaction with the outside server on its homepage or what? Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload