Sagar Rout
Sagar Rout

Reputation: 694

Google Custom Search Internet explorer

implementing Google Custom Search Engine for the search functionality. The functionality is working fine in FF and chrome but not working in Internet Explorer. In internet explorer search results are not coming. It is not working in any kind of IE.

Is this related to any kind of Doctype declaration in the html ?

Upvotes: 0

Views: 990

Answers (2)

Sagar Rout
Sagar Rout

Reputation: 694

It worked by calling the script on windows.onload.

    <script>window.onload = function() {
var cx = 'YOUR_ENGINE_ID';
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>

It worked.

Upvotes: 2

Mike Stratton
Mike Stratton

Reputation: 475

JavaScript errors Check your code to find and fix JavaScript errors.

In Internet Explorer, your status bar will display a warning if any JavaScript errors are discovered on the page. Double-click the warning to see the problem code.

HTML issues Check that your HTML page begins with the declaration.

Code snippet If you have edited your code snippet, try replacing it with the original snippet. (On the Control Panel, click Get code.) It's possible that your page may contain CSS or JavaScript that interferes with the code snippet. To determine if this is the case, try adding the code snippet to an otherwise blank page.

HTTP protocol Make sure that the http:// protocol in your code snippet matches that of your HTML page. Check this line:

Network issues Check that your network is not preventing your page from successfully loading JavaScript and CSS files. In Chrome, right-click the page, click Inspect Element. The Network tab lists the components your web page or application is requesting from web servers, and lists the HTTP request and response headers for each of these resources. If you see a HTTP status code other than "Success" or "Not modified", check that your network is not preventing you from accessing these files. Similarly, you can use the F12 developer tools (Internet Explorer 9), to help diagnose network issues.

Source: https://support.google.com/customsearch/answer/2596433

Upvotes: 0

Related Questions