Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom Google Search
    primarykey
    data
    text
    <p>I want build a custom Google search.</p> <p>I tried <a href="http://www.google.com/cse/tools/create_onthefly" rel="nofollow">this one</a></p> <p><strong>My Code</strong></p> <pre><code>&lt;div&gt; &lt;form id="cse-search-box" action="http://google.com/cse" target='if2'&gt; &lt;input type="hidden" name="cx" value="009827885688477640989:igzwimalyta" /&gt; &lt;input type="hidden" name="ie" value="UTF-8" /&gt; &lt;input type="text" name="q" size="31" /&gt; &lt;input type="button" name="sa" value="Search" onclick="doit()" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;div&gt; &lt;iframe name="if2" id="if2" width="100%" height="600px" marginheight="0" frameborder="0"&gt; &lt;/iframe&gt; &lt;/div&gt; </code></pre> <p>its working. Then I try to remove the height scroll bar when more data is coming from Google. but it is saying error like <strong>Unsafe JavaScript attempt to access frame with URL google.com/… from frame with URL 192.168.9.185/KLMS/CustomGoogleSearch.aspx. Domains, protocols and ports must match</strong></p> <p>so is there any method to fetch the data from Google without using Iframe (like ajax call) [EDIT]</p> <p>I tried</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="CSS/Search.css" /&gt; &lt;script type="text/javascript" src="JS/jquery-1.4.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="JS/CustomSearch.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; &lt;form id="cse-search-box" action="http://google.com/cse" target='if2'&gt; &lt;input type="hidden" name="cx" value="009827885688477640989:igzwimalyta" /&gt; &lt;input type="hidden" name="ie" value="UTF-8" /&gt; &lt;input type="text" name="q" size="31" /&gt; &lt;input type="button" name="sa" value="Search" onclick="doit()" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;div&gt; &lt;form id="frmSearch" runat="server" autocomplete="off"&gt; &lt;div id="mainSearchContainer"&gt; &lt;!-- Container to show Internal search result --&gt; &lt;div class="searchResult"&gt; &lt;!-- Show Item search result (Currently Tip) --&gt; &lt;div class="itemResult"&gt; &lt;fieldset&gt; &lt;legend&gt;Items&lt;/legend&gt; &lt;div class="resultContainer"&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/div&gt; &lt;!-- Show People search result (currently PointCat members) --&gt; &lt;div class="peopleResult"&gt; &lt;fieldset&gt; &lt;legend&gt;People&lt;/legend&gt; &lt;div class="resultContainer"&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;div&gt; &lt;iframe name="if2" id="if2" width="100%" height="600px" marginheight="0" frameborder="0"&gt;&lt;/iframe&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; // get AJAX http request var xmlhttp = getXMLHttpRequest(); function getXMLHttpRequest() { var xhr; if (window.XMLHttpRequest) { //code for IE7+, Firefox, Chrome, Opera, Safari xhr = new XMLHttpRequest(); } else { //code for IE6, IE5 xhr = ActiveXObject("Microsoft.XMLHTTP"); } return xhr; } window.doit = function () { xmlhttp.onreadystatechange = function () { document.forms["cse-search-box"].submit(); if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) { //This is used when AJAX returns //xmlhttp.responseText contains all markup sent back from google //Determine size of iframe $("#if2").attr('width', '100%'); $("#if2").attr('height', textHeight(xmlhttp.responseText) + "px"); //Used to set the contents of the iframe //May have to be adapted to get the response to a specific place in the iframe tag hierarchy $("#if2").attr('src', "data:text/html;charset=UTF-8," + escape(xmlhttp.responseText)); } }; xmlhttp.open("POST", "http://google.com/cse", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send("cx=009827885688477640989:igzwimalyta&amp;ie=UTF-8&amp;q=31"); }; //Measures the size of the returned text function textHeight(text) { $("body").append('&lt;span id="tempSpan" style="display:block;"&gt;' + text + '&lt;/span&gt;'); var height = $("#tempSpan").height(); $("#tempSpan").remove(); return height; }; &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>[/edit]</p> <p>Please help.</p> <p>thanks in advance</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