如何在asp.net webform中实现谷歌模型搜索框 [英] How to implement a google model search box in asp.net webform

查看:124
本文介绍了如何在asp.net webform中实现谷歌模型搜索框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net webform中实现谷歌模型搜索框

解决方案

这是一个完整的工作示例:



 <   html     xmlns   =  http://www.w3.org/1999/xhtml\">  
< head runat = server >
< title > < / title >
< script >
function (){
var cx = ' 012117305473792254352:kosbw5yycts'< /跨度>;
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 >

< / head >
< 正文 >
< 表格 id = form1 runat = server >
< div >
< gcse:search xmlns:gcse = #unknown > < / gcse:search >
< / div >
< / form >
< / body >
< / html >







这个答案最初发布于:



如何在我的网站上使用谷歌搜索? [ ^ ]



您可以从以下链接生成密钥和完整教程:



https://www.google.com/cse/ [ ^ ]


How to implement a google model search box in asp.net webform

解决方案

Here is a complete working example:

<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title></title>
    <script>
        (function () {
            var cx = '012117305473792254352:kosbw5yycts';
            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>
 
</head>
<body>
    <form id="form1"  runat="server">
    <div>
        <gcse:search xmlns:gcse="#unknown"></gcse:search>
    </div>
    </form>
</body>
</html>




This answer was originally posted at:

How do I use google search on my webiste?[^]

You can generate your key and complete tutorial from below link:

https://www.google.com/cse/[^]


这篇关于如何在asp.net webform中实现谷歌模型搜索框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆