1

Ave!

Dear People..

I wanted to make an extension of my "Google Custom Search Code"

to show search results from my website in Extension Popup (popup.html)

I am having issues while making an extension from it.

  1. When I load iframe from local computer The popup is showing Text but the Search Dialog box is not showing.

  2. When I load iframe from GoogleDrive iframe is showing but it takes nearly 3 4 seconds to load.

  3. ------------------ (No. 3 I solved successfully) The Links are not opening in new tab I treid too much please help me to open link in new tab?? (in Google Search API there was an option Search Features> Advance > Target Link ... I put the value _Blank)

Thanks alot!

The codes are as below.

manifest.json

{
    "name": "Instant Search!",
    "description": "Search My Blog Instantly!",

    "version": "0.1",
   "manifest_version": 2,
    "browser_action": {
        "default_popup": "popup.html",
        "default_title": "Search My Blog"
    }

}

Popup.html

<html>
<head>

</head>
    <body>
        <iframe width="400" height="400" 
             seamless="seamless"src="/QS.html"></iframe>
    </body>
</html>

iframe page

 <!DOCTYPE html>
  <html>
  <head>
<style>
.cse input.gsc-input, input.gsc-input {
background-image:url('/blank.gif')!important;
}
</style> 
  </head>
<body>
<script>
  (function() {
    var cx = '009043611225946488903:ntz9nyqubzw';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
        '//www.google.com/cse/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
  })();
</script>
<gcse:search></gcse:search>
</body>
  </html>
4

1 回答 1

0

您的 HTML 代码中没有脚本标签(因此document.getElementsByTagName('script')[0]不存在)

尝试 :

document.body.appendChild(gcse);

代替 :

var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
于 2013-09-29T18:06:17.767 回答