Google 自定义搜索的搜索框中的默认值
我正在使用 Google 自定义搜索的标准复制和粘贴代码(免费,带广告)。我想在页面加载时在搜索字段中显示一些文本,这可能吗?
如果是这样,怎么办?
代码如下:
<div id="cse" style="width: 100%;">Loading</div>
<script src="//www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function() {
var customSearchControl = new google.search.CustomSearchControl('000203232594935527974:aspio6dmwkq');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse');
}, true);
</script>
<link rel="stylesheet" href="//www.google.com/cse/style/look/default.css" type="text/css" />
浮动的默认 Google 徽标和“自定义搜索”字样不会打扰我。
我还想知道是否也可以在页面加载时运行自定义搜索。
I am using the standard copy and paste code for the Google Custom Search (free with ads). I want to have some text in the search field when the page is loaded is that possible?
If so, how?
Here's the code:
<div id="cse" style="width: 100%;">Loading</div>
<script src="//www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function() {
var customSearchControl = new google.search.CustomSearchControl('000203232594935527974:aspio6dmwkq');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse');
}, true);
</script>
<link rel="stylesheet" href="//www.google.com/cse/style/look/default.css" type="text/css" />
The floating default Google logo and words "Custom Search" don't bother me.
I was also wondering if I could run the custom search on page load as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用“仅结果”代码。通过这样做,您可以使用自己的搜索框。
如果您希望某些文本显示在搜索字段中,请尝试以下操作:
Use the "results only" code. By doing so, you can use your own search box.
If you want some text to show up in the search field, try this: