简体   繁体   中英

Custom Google Search doesn't appear on IE8 and IE9

We recently updated our search engine on Google to a custom search. It works fine on Chrome, Firefox and Safari but the search field window doesn't appear in IE8 & IE9. I checked the CSS to see if that was the problem but it doesn't seem to be the issue.

Here is the script that they want us to use, doesn't anyone see an issue for why it wouldn't appear in IE?

<!-- The following javascript appears before the closing </head> tag. -->
<script>
(function() {
var cx = '012938749785999463601:bae5a4ajf2q';
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>
<!-- This tag is inserted where the search box should render -->
 <gcse:searchbox-only></gcse:searchbox-only>

Here is a site page: http://amazingribs.com/tips_and_technique/index2.html

This code works in every other browser. Any ideas?

Thanks

Can you try moving the code somewhere inside the <body> tags?

You have it in the <head> tags, but it refers to document , which might not be "ready" at the time the script executes. By placing it in <body> , document should be available.

Also, I would try changing this:

var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);

To just this:

document.body.appendChild(gcse);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM