Javascript 谷歌自定义网站搜索-促销未显示
我正在使用标准的自定义搜索安装。我已将促销设置到我的帐户 我有以下资料:Javascript 谷歌自定义网站搜索-促销未显示,javascript,google-custom-search,Javascript,Google Custom Search,我正在使用标准的自定义搜索安装。我已将促销设置到我的帐户 我有以下资料: google.load('search', '1', { language: 'en', style: google.loader.themes.MINIMALIST }); google.setOnLoadCallback(function () { var customSearchOptions = {}; customSearchOptions[google.searc
google.load('search', '1', { language: 'en', style: google.loader.themes.MINIMALIST });
google.setOnLoadCallback(function () {
var customSearchOptions = {};
customSearchOptions[google.search.Search.RESTRICT_EXTENDED_ARGS] = { 'as_sitesearch': '' };
var customSearchControl = new google.search.CustomSearchControl('CSE-UNIQUE-ID', customSearchOptions);
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.setAutoComplete(true);
customSearchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
customSearchControl.draw('cse', options);
customSearchControl.execute(getParameterByName("q"));
}, true);
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if (results == null) {
return "";
}
else {
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
}
我正在通过CMS设置javascript对象字段:as_sitesearch,这样代码就可以跨站点使用。当该字段填充了i.e“.example.com”时,促销不会显示在搜索结果中。另一方面,它们在自动完成中显示
当as_sitesearch字段为空时,是否显示促销?为什么会这样
感谢当促销链接链接链接到子域或另一个域时,搜索过滤器会从结果中删除促销,因为它不在as_sitesearch字段中的给定域中 虽然自动完成搜索似乎不使用给定的过滤器,因此显示促销